Skip to content

shadowing this is allowed #12406

Open
Open
@martijnhoekstra

Description

@martijnhoekstra

Compiler version

3.0.0-RC3

Minimized code

class ShadowIt {
  def foo = {
    val this = "shadow"
    this
  }
}

Output

scala.MatchError: shadow (of class java.lang.String)
	at ShadowIt.foo(main.scala:3)
	at main$package$.main(main.scala:8)
	at main.main(main.scala:8)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.Run.invokeMain(Run.scala:133)
	at sbt.Run.execute$1(Run.scala:82)
	at sbt.Run.$anonfun$runWithLoader$5(Run.scala:110)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
	at sbt.TrapExit$App.run(TrapExit.scala:258)
	at java.lang.Thread.run(Thread.java:748)

Expectation

Probably a parse error "expected: Identifier, found: this" or something along those lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogNo work planned on this by the core team for the time being.itype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions