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
dynamic, implicit views, tree checkers, ..., rely on in-place type checking #7176
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7176?orig=1 |
@paulp said: In fact this is a perfect example of the problem with having different semantics for objects and vals. EmptyTree used to be an object, and in those days it would call eq. At some point during reflection changes it became "val EmptyTree", as did NoSymbol. I'm sure there's zero chance anyone was thinking "and part of this change will be upending the semantics of pattern matching on these things." |
@retronym said: // Tree
override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] It happens to be useful in this case that the calls go through == so we have somewhere to intercept/log/analyse. |
@paulp said: |
@retronym said: // typedCompoundTypeTree
newTyper(context.make(templ, self.typeSymbol, decls)).typedRefinement(templ) def typedRefinement(templ: Template) {
val stats = templ.body
namer.enterSyms(stats)
// need to delay rest of typedRefinement to avoid cyclic reference errors
unit.toCheck += { () =>
val stats1 = typedStats(stats, NoSymbol)
// this code kicks in only after typer, so `stats` will never be filled in time
// as a result, most of compound type trees with non-empty stats will fail to reify
// todo. investigate whether something can be done about this
val att = templ.attachments.get[CompoundTypeTreeOriginalAttachment].getOrElse(CompoundTypeTreeOriginalAttachment(Nil, Nil))
templ.removeAttachment[CompoundTypeTreeOriginalAttachment]
templ updateAttachment att.copy(stats = stats1)
for (stat <- stats1 if stat.isDef) {
val member = stat.symbol
if (!(context.owner.ancestors forall
(bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol))) {
member setFlag OVERRIDE
}
}
}
} The lowest friction solution for this would be to make 15% less hacky, we could avoid registering this with Or find some other way to break the cycles. |
@xeno-by said: |
@retronym said: /** Try to apply an implicit conversion to `qual` so that it contains
* a method `name`. If that's ambiguous try taking arguments into
* account using `adaptToArguments`.
*/
def adaptToMemberWithArgs(tree: Tree, qual: Tree, name: Name, mode: Int, reportAmbiguous: Boolean, saveErrors: Boolean): Tree = {
def onError(reportError: => Tree): Tree = {
context.tree match {
case Apply(tree1, args) if (tree1 eq tree) && args.nonEmpty =>
silent(_.typedArgs(args, mode)) match {
case SilentResultValue(xs) =>
val args = xs.asInstanceOf[List[Tree]]
if (args exists (_.isErrorTyped))
reportError
else
adaptToArguments(qual, name, args, WildcardType, reportAmbiguous, saveErrors)
case _ =>
reportError
}
case _ =>
reportError
}
}
silent(_.adaptToMember(qual, HasMember(name), false)) match {
case SilentResultValue(res) => res
case SilentTypeError(err) => onError({if (reportAmbiguous) { context.issue(err) }; setError(tree)})
}
} But if |
@retronym said (edited on Mar 10, 2013 9:37:22 PM UTC): That did leave a few legitimate failures, such as neg/t5696.scala and pos/t5720-ownerous.scala. The updated patch: @@ -5615,7 +5618,7 @@ trait Typers extends Modes with Adaptations with Tags {
}
val alreadyTyped = tree.tpe ne null
- var tree1: Tree = if (alreadyTyped) tree else {
+ val tree11: Tree = if (alreadyTyped) tree else {
printTyping(
ptLine("typing %s: pt = %s".format(ptTree(tree), ptPlugins),
"undetparams" -> context.undetparams,
@@ -5628,6 +5631,7 @@ trait Typers extends Modes with Adaptations with Tags {
)
typed1(tree, mode, dropExistential(ptPlugins))
}
+ val tree1 = tree11.shallowDuplicate |
"What is the typer contract?"
https://groups.google.com/d/topic/scala-internals/jeixpDwxTt8/discussion
This patch to return new tree instances from
Typer#typed
:retronym/scala@scala:2.10.x...retronym:topic/tree-clone
Leads to these failing tests:
https://scala-webapps.epfl.ch/jenkins/job/scala-checkin-manual/830/console
Use of
Tree#==
is the first culprit.The text was updated successfully, but these errors were encountered: