- Notifications
You must be signed in to change notification settings - Fork3.1k
More accurate outer checks in patterns#9504
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
More accurate outer checks in patterns#9504
Uh oh!
There was an error while loading.Please reload this page.
Conversation
67e77b9 to5fff7dcCompare 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.
SethTisue commentedFeb 18, 2021
@lrytz this is the last open ticket or PR for 2.13.5, but it takes time to run the community build. |
Uh oh!
There was an error while loading.Please reload this page.
retronym commentedFeb 18, 2021
I'm happy to leave this until post-2.13.5 |
dwijnand commentedFeb 18, 2021
Agreed, this doesn't look ready to me: |
5fff7dc to670f5c7Compare5bf0524 to6a26cf3Compare| caseTypeRef(pre, _, _)if!pre.isStable=>// e.g. _: Outer#Inner | ||
| false | ||
| caseTypeRef(pre, sym, args)=> | ||
| valtestedBinderClass= 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.scalaindex 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 tocad94ffCompareAvoids eliding outer checks that matter (run/t11534b.scala) andavoids emitting checks that don't (pos/t11534.scala) which avoidscompiler warnings when the tested class doesn't have an outerfield.The latter stops the annoying unchecked warning that appeared sincea recent refactoring made `TermName` a final class.
cad94ff to350bbe7Compare
lrytz left a comment
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=> | ||
| valexpectedClass= 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 onxsbti.ScalaProvider with sbt.internal.inc.ScalaInstance.ScalaProvider2 @unchecked. Seescala/community-build#1400 (comment). I'm going to try to fix this, but work-stealers welcome.
Uh oh!
There was an error while loading.Please reload this page.
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.
Fixesscala/bug#11534