New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More accurate outer checks in patterns #9504
More accurate outer checks in patterns #9504
Conversation
67e77b9
to
5fff7dc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@lrytz this is the last open ticket or PR for 2.13.5, but it takes time to run the community build. |
I'm happy to leave this until post-2.13.5 |
Agreed, this doesn't look ready to me:
|
5fff7dc
to
670f5c7
Compare
5bf0524
to
6a26cf3
Compare
case TypeRef(pre, _, _) if !pre.isStable => // e.g. _: Outer#Inner | ||
false | ||
case TypeRef(pre, sym, args) => | ||
val testedBinderClass = testedBinder.info.upperBound.typeSymbol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also works. Maybe slightly clearer than .upperBound
.
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
index c62510e5b2..894fcd834a 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
@@ -411,7 +411,7 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging {
case TypeRef(pre, _, _) if !pre.isStable => // e.g. _: Outer#Inner
false
case TypeRef(pre, sym, args) =>
- val testedBinderClass = testedBinder.info.upperBound.typeSymbol
+ val testedBinderClass = testedBinder.info.baseClasses.find(_.isClass).getOrElse(NoSymbol)
val testedBinderType = testedBinder.info.baseType(testedBinderClass)
val testedPrefixIsExpectedTypePrefix = pre =:= testedBinderType.prefix
6a26cf3
to
cad94ff
Compare
Avoids eliding outer checks that matter (run/t11534b.scala) and avoids emitting checks that don't (pos/t11534.scala) which avoids compiler warnings when the tested class doesn't have an outer field. The latter stops the annoying unchecked warning that appeared since a recent refactoring made `TermName` a final class.
cad94ff
to
350bbe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky stuff...!
withOuterTest(withOuterTest(orig)(testedBinder, parent))(testedBinder, copyRefinedType(rt, rest, scope)) | ||
case expectedTp => | ||
val expectedClass = expectedTp.typeSymbol | ||
assert(!expectedClass.isRefinementClass, orig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This failed, and I think it's because it's failing on xsbti.ScalaProvider with sbt.internal.inc.ScalaInstance.ScalaProvider2 @unchecked
. See scala/community-build#1400 (comment). I'm going to try to fix this, but work-stealers welcome.
Avoids eliding outer checks that matter (run/t11534b.scala) and
avoids emitting checks that don't (pos/t11534.scala) which avoids
compiler warnings when the tested class doesn't have an outer
field.
The latter stops the annoying unchecked warning that appeared since
a recent refactoring made TermName a final class.
Originally submitted to 2.12.x as #8261.
Fixes scala/bug#11534