-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unintended SafeValue Error #23424
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
base: main
Are you sure you want to change the base?
Unintended SafeValue Error #23424
Conversation
signed CLA |
3d644ef
to
8c06f71
Compare
case v: SafeValue if expr.symbol.is(Flags.Method) => | ||
withTrace(trace2) { call(v, expr.symbol, args = Nil, receiver = qualifier.tpe, superType = NoType) } | ||
case _ => | ||
withTrace(trace2) { select(qual, expr.symbol, receiver = qualifier.tpe) } |
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.
I was thinking, why not always dispatch to call
if the symbol is a method.
If that is the case, maybe it's better to fix the extractor Call
:
scala3/compiler/src/dotty/tools/dotc/transform/init/Util.scala
Lines 44 to 65 in 35c2ef3
def unapply(tree: Tree)(using Context): Option[(Tree, List[List[Arg]])] = | |
tree match | |
case Apply(fn, args) => | |
val argTps = fn.tpe.widen match | |
case mt: MethodType => mt.paramInfos | |
if (args.size != argTps.size) | |
report.warning("[Internal error] Number of arguments do not match number of argument types in " + tree.symbol.name) | |
val normArgs: List[Arg] = args.zip(argTps).map { | |
case (arg, _: ExprType) => ByNameArg(arg) | |
case (arg, _) => arg | |
} | |
unapply(fn) match | |
case Some((ref, args0)) => Some((ref, args0 :+ normArgs)) | |
case None => None | |
case TypeApply(fn, targs) => | |
unapply(fn) | |
case ref: RefTree if ref.tpe.widenSingleton.isInstanceOf[MethodicType] => | |
Some((ref, Nil)) | |
case _ => None |
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.
Great idea! Would that mean that we should change Call
:
case ref: RefTree if ref.symbol.is(Flags.Method) && ref.tpe.widenSingleton.isInstanceOf[MethodicType] =>
Some((ref, Nil))
and leaving the def cases
unchanged?
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.
We can try just keep if ref.symbol.is(Flags.Method)
.
Test case is expected to emit output with
--Ysafe-init-global
, but it emits a safe-value internal error. It is temporarily placed in thepos-tasty
folder.