Last active
December 18, 2015 07:10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scalac -unchecked -Xprint:explicitouter,lambdalift,constructors BugOuterPart1.scala | |
[[syntax trees at end of explicitouter]] // BugOuterPart1.scala | |
package <empty> { | |
class Outer extends Object { | |
def <init>(): Outer = { | |
Outer.super.<init>(); | |
() | |
}; | |
final class Inner extends Object { | |
def <init>($outer: Outer.this.type): Outer.this.Inner = { | |
Inner.super.<init>(); | |
() | |
}; | |
<synthetic> <paramaccessor> private[this] val $outer: Outer.this.type = _; | |
<synthetic> <stable> def Outer$Inner$$$outer(): Outer = Inner.this.$outer | |
} | |
} | |
} | |
[[syntax trees at end of lambdalift]] // BugOuterPart1.scala | |
package <empty> { | |
class Outer extends Object { | |
def <init>(): Outer = { | |
Outer.super.<init>(); | |
() | |
}; | |
final class Inner extends Object { | |
def <init>($outer: Outer): Outer.this.Inner = { | |
Inner.super.<init>(); | |
() | |
}; | |
<synthetic> <paramaccessor> private[this] val $outer: Outer = _; | |
<synthetic> <stable> def Outer$Inner$$$outer(): Outer = Inner.this.$outer | |
} | |
} | |
} | |
[[syntax trees at end of constructors]] // BugOuterPart1.scala | |
package <empty> { | |
class Outer extends Object { | |
final class Inner extends Object { | |
def <init>($outer: Outer): Outer.this.Inner = { | |
Inner.super.<init>(); | |
() | |
} | |
}; | |
def <init>(): Outer = { | |
Outer.super.<init>(); | |
() | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Outer { | |
final class Inner | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scalac -unchecked -Xprint:specialize,explicitouter BugOuterPart2.scala | |
[[syntax trees at end of specialize]] // BugOuterPart2.scala | |
package <empty> { | |
object Matcher extends Object { | |
def <init>(): Matcher.type = { | |
Matcher.super.<init>(); | |
() | |
}; | |
def matchInner(v: Any, o: Outer): Unit = { | |
case <synthetic> val x1: Any = v; | |
case5(){ | |
if (x1.isInstanceOf[o.Inner]().&&((x1.asInstanceOf[o.Inner](): o.Inner).<outer>().eq(o))) | |
matchEnd4(()) | |
else | |
case6() | |
}; | |
case6(){ | |
matchEnd4(throw new MatchError(x1)) | |
}; | |
matchEnd4(x: Unit){ | |
x | |
} | |
} | |
} | |
} | |
BugOuterPart2.scala:4: warning: The outer reference in this type test cannot be checked at run time. | |
case v2: o.Inner => | |
^ | |
[[syntax trees at end of explicitouter]] // BugOuterPart2.scala | |
package <empty> { | |
object Matcher extends Object { | |
def <init>(): Matcher.type = { | |
Matcher.super.<init>(); | |
() | |
}; | |
def matchInner(v: Any, o: Outer): Unit = { | |
case <synthetic> val x1: Any = v; | |
case5(){ | |
if (x1.isInstanceOf[o.Inner]().&&(true)) | |
matchEnd4(()) | |
else | |
case6() | |
}; | |
case6(){ | |
matchEnd4(throw new MatchError(x1)) | |
}; | |
matchEnd4(x: Unit){ | |
x | |
} | |
} | |
} | |
} | |
one warning found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Matcher { | |
def matchInner(v: Any, o: Outer) = | |
v match { | |
case v2: o.Inner => | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment