diff options
Diffstat (limited to 'src')
4 files changed, 74 insertions, 79 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala index a09acc04b8..f6b3c42ca9 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala @@ -41,17 +41,12 @@ trait GenTrees { // the first prototype of reification reified all types and symbols for all trees => this quickly became unyieldy // the second prototype reified external types, but avoided reifying local ones => this created an ugly irregularity // current approach is uniform and compact - var rtree = tree match { - case FreeDef(_, _, _, _, _) => - reifyNestedFreeDef(tree) - case FreeRef(_, _) => - reifyNestedFreeRef(tree) - case BoundTerm(tree) => - reifyBoundTerm(tree) - case BoundType(tree) => - reifyBoundType(tree) - case _ => - reifyTreeSyntactically(tree) + var rtree: Tree = tree match { + case FreeDef(_, _, _, _, _) => reifyNestedFreeDef(tree) + case FreeRef(_, _) => reifyNestedFreeRef(tree) + case BoundTerm(tree) => reifyBoundTerm(tree) + case BoundType(tree) => reifyBoundType(tree) + case _ => reifyTreeSyntactically(tree) } // usually we don't reify symbols/types, because they can be re-inferred during subsequent reflective compilation @@ -68,19 +63,13 @@ trait GenTrees { rtree } - def reifyTreeSyntactically(tree: Tree) = tree match { - case global.EmptyTree => - reifyMirrorObject(EmptyTree) - case global.noSelfType => - mirrorSelect(nme.noSelfType) - case global.pendingSuperCall => - mirrorSelect(nme.pendingSuperCall) - case Literal(const @ Constant(_)) => - mirrorCall(nme.Literal, reifyProduct(const)) - case Import(expr, selectors) => - mirrorCall(nme.Import, reify(expr), mkList(selectors map reifyProduct)) - case _ => - reifyProduct(tree) + def reifyTreeSyntactically(tree: Tree): Tree = tree match { + case global.EmptyTree => reifyMirrorObject(EmptyTree) + case global.noSelfType => mirrorSelect(nme.noSelfType) + case global.pendingSuperCall => mirrorSelect(nme.pendingSuperCall) + case Literal(const @ Constant(_)) => mirrorCall(nme.Literal, reifyProduct(const)) + case Import(expr, selectors) => mirrorCall(nme.Import, reify(expr), mkList(selectors map reifyProduct)) + case _ => reifyProduct(tree) } def reifyFlags(flags: FlagSet) = diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 1f80aa4b6f..01d5791f60 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -176,8 +176,8 @@ trait ScalaSettings extends AbsScalaSettings val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup") val Yreploutdir = StringSetting ("-Yrepl-outdir", "path", "Write repl-generated classfiles to given output directory (use \"\" to generate a temporary dir)" , "") val YmethodInfer = BooleanSetting ("-Yinfer-argument-types", "Infer types for arguments of overriden methods.") - val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition."). - withDeprecationMessage("This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug.") + val etaExpandKeepsStar = BooleanSetting ("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.").withDeprecationMessage(removalIn212) + val inferByName = BooleanSetting ("-Yinfer-by-name", "Allow inference of by-name types. This is a temporary option to ease transition. See SI-7899.").withDeprecationMessage(removalIn212) val Yinvalidate = StringSetting ("-Yinvalidate", "classpath-entry", "Invalidate classpath entry before run", "") val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes") val YdisableUnreachablePrevention = BooleanSetting("-Ydisable-unreachable-prevention", "Disable the prevention of unreachable blocks in code generation.") @@ -185,6 +185,8 @@ trait ScalaSettings extends AbsScalaSettings val exposeEmptyPackage = BooleanSetting("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly() + private def removalIn212 = "This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug." + /** Area-specific debug output. */ val Ydocdebug = BooleanSetting("-Ydoc-debug", "Trace all scaladoc activity.") diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index ccf4a5e46f..dd0923a696 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -913,7 +913,11 @@ trait Infer extends Checkable { val targs = exprTypeArgs(tvars, tparams, treeTp, pt, useWeaklyCompatible) def infer_s = map3(tparams, tvars, targs)((tparam, tvar, targ) => s"$tparam=$tvar/$targ") mkString "," printTyping(tree, s"infer expr instance from pt=$pt, $infer_s") - def targsStrict = if (targs eq null) null else targs mapConserve dropByName + + // SI-7899 infering by-name types is unsound. The correct behaviour is conditional because the hole is + // exploited in Scalaz (Free.scala), as seen in: run/t7899-regression. + def dropByNameIfStrict(tp: Type): Type = if (settings.inferByName) tp else dropByName(tp) + def targsStrict = if (targs eq null) null else targs mapConserve dropByNameIfStrict if (keepNothings || (targs eq null)) { //@M: adjustTypeArgs fails if targs==null, neg/t0226 substExpr(tree, tparams, targsStrict, pt) diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index ccf5cf5249..54a1913b96 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1758,59 +1758,59 @@ trait Trees extends api.Trees { self: SymbolTable => // -------------- Classtags -------------------------------------------------------- - implicit val TreeTag = ClassTag[Tree](classOf[Tree]) - implicit val TermTreeTag = ClassTag[TermTree](classOf[TermTree]) - implicit val TypTreeTag = ClassTag[TypTree](classOf[TypTree]) - implicit val SymTreeTag = ClassTag[SymTree](classOf[SymTree]) - implicit val NameTreeTag = ClassTag[NameTree](classOf[NameTree]) - implicit val RefTreeTag = ClassTag[RefTree](classOf[RefTree]) - implicit val DefTreeTag = ClassTag[DefTree](classOf[DefTree]) - implicit val MemberDefTag = ClassTag[MemberDef](classOf[MemberDef]) - implicit val PackageDefTag = ClassTag[PackageDef](classOf[PackageDef]) - implicit val ImplDefTag = ClassTag[ImplDef](classOf[ImplDef]) - implicit val ClassDefTag = ClassTag[ClassDef](classOf[ClassDef]) - implicit val ModuleDefTag = ClassTag[ModuleDef](classOf[ModuleDef]) - implicit val ValOrDefDefTag = ClassTag[ValOrDefDef](classOf[ValOrDefDef]) - implicit val ValDefTag = ClassTag[ValDef](classOf[ValDef]) - implicit val DefDefTag = ClassTag[DefDef](classOf[DefDef]) - implicit val TypeDefTag = ClassTag[TypeDef](classOf[TypeDef]) - implicit val LabelDefTag = ClassTag[LabelDef](classOf[LabelDef]) - implicit val ImportSelectorTag = ClassTag[ImportSelector](classOf[ImportSelector]) - implicit val ImportTag = ClassTag[Import](classOf[Import]) - implicit val TemplateTag = ClassTag[Template](classOf[Template]) - implicit val BlockTag = ClassTag[Block](classOf[Block]) - implicit val CaseDefTag = ClassTag[CaseDef](classOf[CaseDef]) - implicit val AlternativeTag = ClassTag[Alternative](classOf[Alternative]) - implicit val StarTag = ClassTag[Star](classOf[Star]) - implicit val BindTag = ClassTag[Bind](classOf[Bind]) - implicit val UnApplyTag = ClassTag[UnApply](classOf[UnApply]) - implicit val FunctionTag = ClassTag[Function](classOf[Function]) - implicit val AssignTag = ClassTag[Assign](classOf[Assign]) - implicit val AssignOrNamedArgTag = ClassTag[AssignOrNamedArg](classOf[AssignOrNamedArg]) - implicit val IfTag = ClassTag[If](classOf[If]) - implicit val MatchTag = ClassTag[Match](classOf[Match]) - implicit val ReturnTag = ClassTag[Return](classOf[Return]) - implicit val TryTag = ClassTag[Try](classOf[Try]) - implicit val ThrowTag = ClassTag[Throw](classOf[Throw]) - implicit val NewTag = ClassTag[New](classOf[New]) - implicit val TypedTag = ClassTag[Typed](classOf[Typed]) - implicit val GenericApplyTag = ClassTag[GenericApply](classOf[GenericApply]) - implicit val TypeApplyTag = ClassTag[TypeApply](classOf[TypeApply]) - implicit val ApplyTag = ClassTag[Apply](classOf[Apply]) - implicit val SuperTag = ClassTag[Super](classOf[Super]) - implicit val ThisTag = ClassTag[This](classOf[This]) - implicit val SelectTag = ClassTag[Select](classOf[Select]) - implicit val IdentTag = ClassTag[Ident](classOf[Ident]) - implicit val ReferenceToBoxedTag = ClassTag[ReferenceToBoxed](classOf[ReferenceToBoxed]) - implicit val LiteralTag = ClassTag[Literal](classOf[Literal]) - implicit val AnnotatedTag = ClassTag[Annotated](classOf[Annotated]) - implicit val SingletonTypeTreeTag = ClassTag[SingletonTypeTree](classOf[SingletonTypeTree]) - implicit val SelectFromTypeTreeTag = ClassTag[SelectFromTypeTree](classOf[SelectFromTypeTree]) - implicit val CompoundTypeTreeTag = ClassTag[CompoundTypeTree](classOf[CompoundTypeTree]) - implicit val AppliedTypeTreeTag = ClassTag[AppliedTypeTree](classOf[AppliedTypeTree]) - implicit val TypeBoundsTreeTag = ClassTag[TypeBoundsTree](classOf[TypeBoundsTree]) + implicit val AlternativeTag = ClassTag[Alternative](classOf[Alternative]) + implicit val AnnotatedTag = ClassTag[Annotated](classOf[Annotated]) + implicit val AppliedTypeTreeTag = ClassTag[AppliedTypeTree](classOf[AppliedTypeTree]) + implicit val ApplyTag = ClassTag[Apply](classOf[Apply]) + implicit val AssignOrNamedArgTag = ClassTag[AssignOrNamedArg](classOf[AssignOrNamedArg]) + implicit val AssignTag = ClassTag[Assign](classOf[Assign]) + implicit val BindTag = ClassTag[Bind](classOf[Bind]) + implicit val BlockTag = ClassTag[Block](classOf[Block]) + implicit val CaseDefTag = ClassTag[CaseDef](classOf[CaseDef]) + implicit val ClassDefTag = ClassTag[ClassDef](classOf[ClassDef]) + implicit val CompoundTypeTreeTag = ClassTag[CompoundTypeTree](classOf[CompoundTypeTree]) + implicit val DefDefTag = ClassTag[DefDef](classOf[DefDef]) + implicit val DefTreeTag = ClassTag[DefTree](classOf[DefTree]) implicit val ExistentialTypeTreeTag = ClassTag[ExistentialTypeTree](classOf[ExistentialTypeTree]) - implicit val TypeTreeTag = ClassTag[TypeTree](classOf[TypeTree]) + implicit val FunctionTag = ClassTag[Function](classOf[Function]) + implicit val GenericApplyTag = ClassTag[GenericApply](classOf[GenericApply]) + implicit val IdentTag = ClassTag[Ident](classOf[Ident]) + implicit val IfTag = ClassTag[If](classOf[If]) + implicit val ImplDefTag = ClassTag[ImplDef](classOf[ImplDef]) + implicit val ImportSelectorTag = ClassTag[ImportSelector](classOf[ImportSelector]) + implicit val ImportTag = ClassTag[Import](classOf[Import]) + implicit val LabelDefTag = ClassTag[LabelDef](classOf[LabelDef]) + implicit val LiteralTag = ClassTag[Literal](classOf[Literal]) + implicit val MatchTag = ClassTag[Match](classOf[Match]) + implicit val MemberDefTag = ClassTag[MemberDef](classOf[MemberDef]) + implicit val ModuleDefTag = ClassTag[ModuleDef](classOf[ModuleDef]) + implicit val NameTreeTag = ClassTag[NameTree](classOf[NameTree]) + implicit val NewTag = ClassTag[New](classOf[New]) + implicit val PackageDefTag = ClassTag[PackageDef](classOf[PackageDef]) + implicit val RefTreeTag = ClassTag[RefTree](classOf[RefTree]) + implicit val ReferenceToBoxedTag = ClassTag[ReferenceToBoxed](classOf[ReferenceToBoxed]) + implicit val ReturnTag = ClassTag[Return](classOf[Return]) + implicit val SelectFromTypeTreeTag = ClassTag[SelectFromTypeTree](classOf[SelectFromTypeTree]) + implicit val SelectTag = ClassTag[Select](classOf[Select]) + implicit val SingletonTypeTreeTag = ClassTag[SingletonTypeTree](classOf[SingletonTypeTree]) + implicit val StarTag = ClassTag[Star](classOf[Star]) + implicit val SuperTag = ClassTag[Super](classOf[Super]) + implicit val SymTreeTag = ClassTag[SymTree](classOf[SymTree]) + implicit val TemplateTag = ClassTag[Template](classOf[Template]) + implicit val TermTreeTag = ClassTag[TermTree](classOf[TermTree]) + implicit val ThisTag = ClassTag[This](classOf[This]) + implicit val ThrowTag = ClassTag[Throw](classOf[Throw]) + implicit val TreeTag = ClassTag[Tree](classOf[Tree]) + implicit val TryTag = ClassTag[Try](classOf[Try]) + implicit val TypTreeTag = ClassTag[TypTree](classOf[TypTree]) + implicit val TypeApplyTag = ClassTag[TypeApply](classOf[TypeApply]) + implicit val TypeBoundsTreeTag = ClassTag[TypeBoundsTree](classOf[TypeBoundsTree]) + implicit val TypeDefTag = ClassTag[TypeDef](classOf[TypeDef]) + implicit val TypeTreeTag = ClassTag[TypeTree](classOf[TypeTree]) + implicit val TypedTag = ClassTag[Typed](classOf[Typed]) + implicit val UnApplyTag = ClassTag[UnApply](classOf[UnApply]) + implicit val ValDefTag = ClassTag[ValDef](classOf[ValDef]) + implicit val ValOrDefDefTag = ClassTag[ValOrDefDef](classOf[ValOrDefDef]) val treeNodeCount = Statistics.newView("#created tree nodes")(nodeCount) } |