From e4ad8a1b7cdbd4320439d536ffbe07a9995833f1 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 24 May 2023 13:47:31 +0200 Subject: [PATCH 01/11] Simplify avoidance of non-picklable types of Hole [Cherry-picked 87647788cb6dc5175ba298e51c8e08c435f6cfe9] --- .../tools/dotc/transform/PickleQuotes.scala | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala index 15a1a823589c..8b58f18bca52 100644 --- a/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala @@ -17,13 +17,13 @@ import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.untpd import dotty.tools.dotc.config.ScalaRelease.* -import scala.collection.mutable import dotty.tools.dotc.core.Annotations._ import dotty.tools.dotc.core.StdNames._ import dotty.tools.dotc.quoted._ import dotty.tools.dotc.inlines.Inlines import scala.annotation.constructorOnly +import scala.collection.mutable /** Translates quoted terms and types to `unpickleExprV2` or `unpickleType` method calls. * @@ -106,16 +106,19 @@ class PickleQuotes extends MacroTransform { private def extractHolesContents(quote: tpd.Quote)(using Context): (List[Tree], tpd.Quote) = class HoleContentExtractor extends Transformer: private val holeContents = List.newBuilder[Tree] + private val stagedClasses = mutable.HashSet.empty[Symbol] override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match case tree @ Hole(isTerm, _, _, content) => assert(isTerm) assert(!content.isEmpty) holeContents += content - val holeType = getTermHoleType(tree.tpe) + val holeType = getPicklableHoleType(tree.tpe, stagedClasses) val hole = untpd.cpy.Hole(tree)(content = EmptyTree).withType(holeType) cpy.Inlined(tree)(EmptyTree, Nil, hole) case tree: DefTree => + if tree.symbol.isClass then + stagedClasses += tree.symbol val newAnnotations = tree.symbol.annotations.mapconserve { annot => annot.derivedAnnotation(transform(annot.tree)(using ctx.withOwner(tree.symbol))) } @@ -134,19 +137,6 @@ class PickleQuotes extends MacroTransform { } } - /** Remove references to local types that will not be defined in this quote */ - private def getTermHoleType(using Context) = new TypeMap() { - override def apply(tp: Type): Type = tp match - case tp @ TypeRef(NoPrefix, _) => - // reference to term with a type defined in outer quote - getTypeHoleType(tp) - case tp @ TermRef(NoPrefix, _) => - // widen term refs to terms defined in outer quote - apply(tp.widenTermRefExpr) - case tp => - mapOver(tp) - } - /** Get the holeContents of the transformed tree */ def getContents() = val res = holeContents.result @@ -196,11 +186,11 @@ class PickleQuotes extends MacroTransform { cpy.Quote(quote)(Block(tdefs, body1), quote.tags) private def mkTagSymbolAndAssignType(typeArg: Tree, idx: Int)(using Context): TypeDef = { - val holeType = getTypeHoleType(typeArg.tpe.select(tpnme.Underlying)) + val holeType = getPicklableHoleType(typeArg.tpe.select(tpnme.Underlying), _ => false) val hole = untpd.cpy.Hole(typeArg)(isTerm = false, idx, Nil, EmptyTree).withType(holeType) val local = newSymbol( owner = ctx.owner, - name = UniqueName.fresh(hole.tpe.dealias.typeSymbol.name.toTypeName), + name = UniqueName.fresh(typeArg.symbol.name.toTypeName), flags = Synthetic, info = TypeAlias(typeArg.tpe.select(tpnme.Underlying)), coord = typeArg.span @@ -209,25 +199,11 @@ class PickleQuotes extends MacroTransform { ctx.typeAssigner.assignType(untpd.TypeDef(local.name, hole), local).withSpan(typeArg.span) } - /** Remove references to local types that will not be defined in this quote */ - private def getTypeHoleType(using Context) = new TypeMap() { - override def apply(tp: Type): Type = tp match - case tp: TypeRef if tp.typeSymbol.isTypeSplice => - apply(tp.dealias) - case tp @ TypeRef(pre, _) if isLocalPath(pre) => - val hiBound = tp.typeSymbol.info match - case info: ClassInfo => info.parents.reduce(_ & _) - case info => info.hiBound - apply(hiBound) - case tp => - mapOver(tp) - - private def isLocalPath(tp: Type): Boolean = tp match - case NoPrefix => true - case tp: TermRef if !tp.symbol.is(Package) => isLocalPath(tp.prefix) - case tp => false - } - + /** Avoid all non-static types except those defined in the quote. */ + private def getPicklableHoleType(tpe: Type, isStagedClasses: Symbol => Boolean)(using Context) = + new TypeOps.AvoidMap { + def toAvoid(tp: NamedType) = !isStagedClasses(tp.typeSymbol) && !isStaticPrefix(tp) + }.apply(tpe) } object PickleQuotes { From 505ad3124815024f3e71212415c36fc219ed7714 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 24 May 2023 11:19:39 +0200 Subject: [PATCH 02/11] Fix pattern generation in "ordinal" mirror method The "ordinal" method generated non-sensical patterns if the cases of a sealed trait were found in the trait itself. In that case the ordinal method would be placed in the companion object, but still tried to access the cases via the `this` of the companion class. We are now more careful and fall back to type projections in comparisons. Fixes #17556 [Cherry-picked a0be3d6cf703c40707e241f288373fa46b432e8a] --- .../tools/dotc/core/SymDenotations.scala | 33 ++++++++++++++++--- .../dotty/tools/dotc/transform/SymUtils.scala | 4 --- .../dotc/transform/SyntheticMembers.scala | 2 +- tests/pos/i17556.scala | 8 +++++ 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 tests/pos/i17556.scala diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index b8c17ff61e9e..2ee750acc84f 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1513,16 +1513,29 @@ object SymDenotations { * See tests/pos/i10769.scala */ def reachableTypeRef(using Context) = - TypeRef(owner.reachableThisType, symbol) + TypeRef(owner.reachablePrefix, symbol) - /** Like termRef, but objects in the prefix are represented by their singleton type, + /** The reachable typeRef with wildcard arguments for each type parameter */ + def reachableRawTypeRef(using Context) = + reachableTypeRef.appliedTo(typeParams.map(_ => TypeBounds.emptyPolyKind)) + + /** Like termRef, if it is addressable from the current context, + * but objects in the prefix are represented by their singleton type, * this means we output `pre.O.member` rather than `pre.O$.this.member`. * * This is required to avoid owner crash in ExplicitOuter. * See tests/pos/i10769.scala + * + * If the reference is to an object that is not accessible from the + * current context since the object is nested in a class that is not an outer + * class of the current context, fall back to a TypeRef to the module class. + * Test case is tests/pos/i17556.scala. + * If the reference is to some other inaccessible object, throw an AssertionError. */ - def reachableTermRef(using Context) = - TermRef(owner.reachableThisType, symbol) + def reachableTermRef(using Context): Type = owner.reachablePrefix match + case pre: SingletonType => TermRef(pre, symbol) + case pre if symbol.is(ModuleVal) => TypeRef(pre, symbol.moduleClass) + case _ => throw AssertionError(i"cannot compute path to TermRef $this from ${ctx.owner}") /** Like thisType, but objects in the type are represented by their singleton type, * this means we output `pre.O.member` rather than `pre.O$.this.member`. @@ -1537,6 +1550,18 @@ object SymDenotations { else ThisType.raw(TypeRef(owner.reachableThisType, symbol.asType)) + /** Like `reachableThisType`, except if that would refer to a class where + * the `this` cannot be accessed. In that case, fall back to the + * rawTypeRef of the class. E.g. instead of `A.this.X` where `A.this` + * is inaccessible, use `A#X`. + */ + def reachablePrefix(using Context): Type = reachableThisType match + case pre: ThisType + if !pre.cls.isStaticOwner && !ctx.owner.isContainedIn(pre.cls) => + pre.cls.reachableRawTypeRef + case pre => + pre + /** The variance of this type parameter or type member as a subset of * {Covariant, Contravariant} */ diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala index c02a7d90cb8c..3fe05a45699e 100644 --- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala @@ -333,10 +333,6 @@ object SymUtils: else owner.isLocal } - /** The reachable typeRef with wildcard arguments for each type parameter */ - def reachableRawTypeRef(using Context) = - self.reachableTypeRef.appliedTo(self.typeParams.map(_ => TypeBounds.emptyPolyKind)) - /** Is symbol a type splice operation? */ def isTypeSplice(using Context): Boolean = self == defn.QuotedType_splice diff --git a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala index 48bcbaab3511..1560ae6e5618 100644 --- a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala +++ b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala @@ -552,7 +552,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) { .map((pre, child) => rawRef(child).asSeenFrom(pre, child.owner)) case _ => cls.children.map(rawRef) - end computeChildTypes + val childTypes = computeChildTypes val cases = for (patType, idx) <- childTypes.zipWithIndex yield diff --git a/tests/pos/i17556.scala b/tests/pos/i17556.scala new file mode 100644 index 000000000000..9f14cbfbb7c1 --- /dev/null +++ b/tests/pos/i17556.scala @@ -0,0 +1,8 @@ +sealed trait A { + // must be `object` or `case class` + object X extends A + case class Y() extends A +} + +// companion object must exist +object A \ No newline at end of file From dae0fd5bde22ba3e0fc2831c875c9350965b1cff Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Wed, 24 May 2023 17:44:52 +0200 Subject: [PATCH 03/11] test: add in a regression test for #15913 [skip community_build] closes #15913 [Cherry-picked cbd0851826024c4aaac33f155ab1e830bfaf8882] --- tests/run/i15913.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/run/i15913.scala diff --git a/tests/run/i15913.scala b/tests/run/i15913.scala new file mode 100644 index 000000000000..f3e98a3bfd6a --- /dev/null +++ b/tests/run/i15913.scala @@ -0,0 +1,20 @@ +// https://github.com/lampepfl/dotty/issues/15913 + +class injector[F] + +object injectorFactory { + def apply[F](overrides: String*): injector[F] = new injector[F] + + def apply[F]( + bootstrapActivation: Int = ???, + overrides: Seq[String] = Seq.empty, + ): injector[F] = new injector[F] +} + +object Test extends App { + println( + injectorFactory[String]( + bootstrapActivation = 0 + ) + ) +} From 2327f1eb9194c3f66bf7e1f4cd0543c62dac47e7 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 24 May 2023 15:40:22 +0200 Subject: [PATCH 04/11] Fix superType of SuperType I am not quite sure abput he previous definition of superType in SuperType. I believe it's probably needed for something. But it's clearly wrong if the `supertpe` argument does not have a symbol. We now fall back to the default `superType = underlying` in this case. Fixes $17555 [Cherry-picked 810a3965b46b7fa992fbaf3249c41739ad108192] --- compiler/src/dotty/tools/dotc/core/Types.scala | 3 ++- tests/run/i17555.scala | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/run/i17555.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 7282905f559f..54f8ca02eb4a 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3037,7 +3037,8 @@ object Types { abstract case class SuperType(thistpe: Type, supertpe: Type) extends CachedProxyType with SingletonType { override def underlying(using Context): Type = supertpe override def superType(using Context): Type = - thistpe.baseType(supertpe.typeSymbol) + if supertpe.typeSymbol.exists then thistpe.baseType(supertpe.typeSymbol) + else super.superType def derivedSuperType(thistpe: Type, supertpe: Type)(using Context): Type = if ((thistpe eq this.thistpe) && (supertpe eq this.supertpe)) this else SuperType(thistpe, supertpe) diff --git a/tests/run/i17555.scala b/tests/run/i17555.scala new file mode 100644 index 000000000000..323d252eac8a --- /dev/null +++ b/tests/run/i17555.scala @@ -0,0 +1,17 @@ +class Root { + override def toString() = "Root" +} +trait A extends Root with B { } +trait B { + override def toString() = "B" +} +case class C() extends A { + override def toString() = super.toString() +} +class D() extends A, Serializable { + override def toString() = super.toString() +} + +@main def Test = + println(C()) + println(D()) \ No newline at end of file From 548513d5f9b5bbb6f3f320dded0402b8fc4daba1 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 24 May 2023 16:31:47 +0200 Subject: [PATCH 05/11] Change println to assert in run test [Cherry-picked d1a7346de0f312c396f63973669d1c5633634538] --- tests/run/i17555.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run/i17555.scala b/tests/run/i17555.scala index 323d252eac8a..6458cb7f7efb 100644 --- a/tests/run/i17555.scala +++ b/tests/run/i17555.scala @@ -13,5 +13,5 @@ class D() extends A, Serializable { } @main def Test = - println(C()) - println(D()) \ No newline at end of file + assert(C().toString == "B") + assert(D().toString == "B") From 64feca3b4c9335aaef70a74e5654cfed49a95c87 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 25 May 2023 15:21:47 +0200 Subject: [PATCH 06/11] Refactor: Redirection to boundary/break instead of scala.util.control.NonLocalReturns [Cherry-picked 3502cef38aa6d396e737fda33f5bb7a1dfe988e4] --- .../dropped-features/nonlocal-returns.md | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/_docs/reference/dropped-features/nonlocal-returns.md b/docs/_docs/reference/dropped-features/nonlocal-returns.md index 17b86f77ee56..e6490b7ca5bc 100644 --- a/docs/_docs/reference/dropped-features/nonlocal-returns.md +++ b/docs/_docs/reference/dropped-features/nonlocal-returns.md @@ -9,21 +9,17 @@ Returning from nested anonymous functions has been deprecated, and will produce Nonlocal returns are implemented by throwing and catching `scala.runtime.NonLocalReturnException`-s. This is rarely what is intended by the programmer. It can be problematic because of the hidden performance cost of throwing and catching exceptions. Furthermore, it is a leaky implementation: a catch-all exception handler can intercept a `NonLocalReturnException`. -A drop-in library replacement is provided in [`scala.util.control.NonLocalReturns`](https://scala-lang.org/api/3.x/scala/util/control/NonLocalReturns$.html). Example: +A better alternative to nonlocal returns and also the `scala.util.control.Breaks` API is provided by [`scala.util.boundary` and `boundary.break`](http://dotty.epfl.ch/api/scala/util/boundary$.html). -```scala -import scala.util.control.NonLocalReturns.* - -extension [T](xs: List[T]) - def has(elem: T): Boolean = returning { - for x <- xs do - if x == elem then throwReturn(true) - false - } +Example: -@main def test(): Unit = - val xs = List(1, 2, 3, 4, 5) - assert(xs.has(2) == xs.contains(2)) +```scala +import scala.util.boundary, boundary.break +def firstIndex[T](xs: List[T], elem: T): Int = + boundary: + for (x, i) <- xs.zipWithIndex do + if x == elem then break(i) + -1 ``` Note: compiler produces deprecation error on nonlocal returns only with `-source:future` option. From 252bc8087ad656b97beb1341abbaf673057b4c4c Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Fri, 26 May 2023 12:50:52 +0200 Subject: [PATCH 07/11] docs: remove empty "changes in type checking" page (#17494) This relates to https://github.com/lampepfl/dotty/issues/10759. Just as a general rule of thumb, I don't think we should have fully empty pages in documentation like this. It's not a great look to the outside world. [skip community_build] refs: https://github.com/lampepfl/dotty/issues/10759 [Cherry-picked a682211d70f8cb9f98d913f7550be244942c9688] --- docs/_docs/reference/changed-features/type-checking.md | 7 ------- docs/sidebar.yml | 1 - project/resources/referenceReplacements/sidebar.yml | 1 - .../scripts/expected-links/reference-expected-links.txt | 1 - 4 files changed, 10 deletions(-) delete mode 100644 docs/_docs/reference/changed-features/type-checking.md diff --git a/docs/_docs/reference/changed-features/type-checking.md b/docs/_docs/reference/changed-features/type-checking.md deleted file mode 100644 index 6f59b1a1c1c6..000000000000 --- a/docs/_docs/reference/changed-features/type-checking.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: doc-page -title: "Changes in Type Checking" -nightlyOf: https://docs.scala-lang.org/scala3/reference/changed-features/type-checking.html ---- - -*** **TO BE FILLED IN** *** diff --git a/docs/sidebar.yml b/docs/sidebar.yml index 345134cf2e9b..30ad05d18cf1 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -92,7 +92,6 @@ subsection: - page: reference/changed-features/operators.md - page: reference/changed-features/wildcards.md - page: reference/changed-features/imports.md - - page: reference/changed-features/type-checking.md - page: reference/changed-features/type-inference.md - page: reference/changed-features/implicit-resolution.md - page: reference/changed-features/implicit-conversions.md diff --git a/project/resources/referenceReplacements/sidebar.yml b/project/resources/referenceReplacements/sidebar.yml index be67a0d6da99..de0f3d7bec2c 100644 --- a/project/resources/referenceReplacements/sidebar.yml +++ b/project/resources/referenceReplacements/sidebar.yml @@ -88,7 +88,6 @@ subsection: - page: reference/changed-features/operators.md - page: reference/changed-features/wildcards.md - page: reference/changed-features/imports.md - - page: reference/changed-features/type-checking.md - page: reference/changed-features/type-inference.md - page: reference/changed-features/implicit-resolution.md - page: reference/changed-features/implicit-conversions.md diff --git a/project/scripts/expected-links/reference-expected-links.txt b/project/scripts/expected-links/reference-expected-links.txt index a09737574c1d..0fbb84831e37 100644 --- a/project/scripts/expected-links/reference-expected-links.txt +++ b/project/scripts/expected-links/reference-expected-links.txt @@ -18,7 +18,6 @@ ./changed-features/pattern-matching.html ./changed-features/structural-types-spec.html ./changed-features/structural-types.html -./changed-features/type-checking.html ./changed-features/type-inference.html ./changed-features/vararg-splices.html ./changed-features/wildcards.html From 8c6e0824e0beac1d8a9aed824f364c54040fe3cb Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 25 May 2023 17:23:27 +0200 Subject: [PATCH 08/11] Refine override exclude criterion for export forwarders Fixes #17588 [Cherry-picked 26170ecad249bac8f43f93627d712f77de24335d] --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 5 ++++- tests/pos/i17588.scala | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i17588.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index cc4433f75a68..df708057dd71 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1122,7 +1122,10 @@ class Namer { typer: Typer => No("is already an extension method, cannot be exported into another one") else if targets.contains(alias) then No(i"clashes with another export in the same export clause") - else if sym.is(Override) then + else if sym.is(Override) || sym.is(JavaDefined) then + // The tests above are used to avoid futile searches of `allOverriddenSymbols`. + // Scala defined symbols can override concrete symbols only if declared override. + // For Java defined symbols, this does not hold, so we have to search anyway. sym.allOverriddenSymbols.find( other => cls.derivesFrom(other.owner) && !other.is(Deferred) ) match diff --git a/tests/pos/i17588.scala b/tests/pos/i17588.scala new file mode 100644 index 000000000000..5ac63d0dcc05 --- /dev/null +++ b/tests/pos/i17588.scala @@ -0,0 +1,2 @@ +class StringBox(inner: String): + export inner.* \ No newline at end of file From 1848693ff37358a201f9da1ed2fe2f57f0cedc7f Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 25 May 2023 17:24:20 +0200 Subject: [PATCH 09/11] Doc comment fix in Parser We did not allow `using` in function types for a long time. [Cherry-picked edeb4b88fff4fca1305f3deae05c2d27837df244] --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 7a29ac3f7a38..3079b26df6cd 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1468,8 +1468,8 @@ object Parsers { * PolyFunType ::= HKTypeParamClause '=>' Type * | HKTypeParamClause ‘->’ [CaptureSet] Type -- under pureFunctions * FunTypeArgs ::= InfixType - * | `(' [ [ ‘[using]’ ‘['erased'] FunArgType {`,' FunArgType } ] `)' - * | '(' [ ‘[using]’ ‘['erased'] TypedFunParam {',' TypedFunParam } ')' + * | `(' [ [ ‘['erased'] FunArgType {`,' FunArgType } ] `)' + * | '(' [ ‘['erased'] TypedFunParam {',' TypedFunParam } ')' */ def typ(): Tree = val start = in.offset From cc33c46962e5031572b9babc58ef4af41e58adad Mon Sep 17 00:00:00 2001 From: odersky Date: Thu, 25 May 2023 22:17:23 +0200 Subject: [PATCH 10/11] Update exclude list Not sure why one out of +100 methods in Java did not get a position in the forwarder [Cherry-picked d9fcb9a02fdd5c9b92adf0fafda5fdaf9caae0ad] --- compiler/test/dotc/pos-test-pickling.blacklist | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist index 9888916a86c9..81c0d3e35d3a 100644 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ b/compiler/test/dotc/pos-test-pickling.blacklist @@ -22,6 +22,7 @@ i15922.scala t5031_2.scala i16997.scala i7414.scala +i17588.scala # Tree is huge and blows stack for printing Text i7034.scala From d22f8db792abab0bb3ebeb57d8ca281192f52751 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 26 May 2023 10:22:37 +0200 Subject: [PATCH 11/11] Remove dead code from ClassfileParser [Cherry-picked be8d626e123d4bb3dd22cc1a55adcbc11baa9084] --- .../src/dotty/tools/dotc/core/classfile/ClassfileParser.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 0c701eb03d38..71e00f985584 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -991,7 +991,9 @@ class ClassfileParser( return unpickleTASTY(tastyBytes) } } - else return unpickleTASTY(bytes) + else + // Before 3.0.0 we had a mode where we could embed the TASTY bytes in the classfile. This has not been supported in any stable release. + report.error(s"Found a TASTY attribute with a length different from 16 in $classfile. This is likely a bug in the compiler. Please report.", NoSourcePosition) } if scan(tpnme.ScalaATTR) && !scalaUnpickleWhitelist.contains(classRoot.name)