diff --git a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala index 41d6bf1f4fae..73acc24c38c2 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeUtils.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeUtils.scala @@ -127,6 +127,16 @@ class TypeUtils: case mt: MethodType => mt.isImplicitMethod || mt.resType.takesImplicitParams case _ => false + /** Is this a type deriving only from transparent classes? + * @param traitOnly if true, all class symbols must be transparent traits + */ + def isTransparent(traitOnly: Boolean = false)(using Context): Boolean = self match + case AndType(tp1, tp2) => + tp1.isTransparent(traitOnly) && tp2.isTransparent(traitOnly) + case _ => + val cls = self.underlyingClassRef(refinementOK = false).typeSymbol + cls.isTransparentClass && (!traitOnly || cls.is(Trait)) + /** The constructors of this type that are applicable to `argTypes`, without needing * an implicit conversion. Curried constructors are always excluded. * @param adaptVarargs if true, allow a constructor with just a varargs argument to diff --git a/compiler/src/dotty/tools/dotc/transform/Dependencies.scala b/compiler/src/dotty/tools/dotc/transform/Dependencies.scala index 733f4601e363..28fd21200759 100644 --- a/compiler/src/dotty/tools/dotc/transform/Dependencies.scala +++ b/compiler/src/dotty/tools/dotc/transform/Dependencies.scala @@ -29,7 +29,7 @@ abstract class Dependencies(root: ast.tpd.Tree, @constructorOnly rootContext: Co def tracked: Iterable[Symbol] = free.keys /** The outermost class that captures all free variables of a function - * that are captured by enclosinh classes (this means that the function could + * that are captured by enclosing classes (this means that the function could * be placed in that class without having to add more environment parameters) */ def logicalOwner: collection.Map[Symbol, Symbol] = logicOwner diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala index 3fbdf1fa5427..6a7dee2ff4fe 100644 --- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -127,7 +127,9 @@ object LambdaLift: private def proxy(sym: Symbol)(using Context): Symbol = { def liftedEnclosure(sym: Symbol) = - deps.logicalOwner.getOrElse(sym, sym.enclosure) + if sym.is(Method) + then deps.logicalOwner.getOrElse(sym, sym.enclosure) + else sym.enclosure def searchIn(enclosure: Symbol): Symbol = { if (!enclosure.exists) { def enclosures(encl: Symbol): List[Symbol] = diff --git a/compiler/test/dotc/neg-best-effort-pickling.excludelist b/compiler/test/dotc/neg-best-effort-pickling.excludelist deleted file mode 100644 index 99a83a467f08..000000000000 --- a/compiler/test/dotc/neg-best-effort-pickling.excludelist +++ /dev/null @@ -1,23 +0,0 @@ -export-in-extension.scala -i12456.scala -i8623.scala -i1642.scala -i16696.scala -constructor-proxy-values.scala -i9328.scala -i15414.scala -i6796.scala -i14013.scala -toplevel-cyclic -curried-dependent-ift.scala -i17121.scala -illegal-match-types.scala -i13780-1.scala -i20317a.scala -i11226.scala -i974.scala -i13864.scala - -# semantic db generation fails in the first compilation -i1642.scala -i15158.scala diff --git a/compiler/test/dotc/neg-best-effort-unpickling.excludelist b/compiler/test/dotc/neg-best-effort-unpickling.excludelist deleted file mode 100644 index 1e22d919f25a..000000000000 --- a/compiler/test/dotc/neg-best-effort-unpickling.excludelist +++ /dev/null @@ -1,17 +0,0 @@ -# cyclic reference crashes -i4368.scala -i827.scala -cycles.scala -i5332.scala -i4369c.scala -i1806.scala -i0091-infpaths.scala -exports.scala -i14834.scala - -# other type related crashes -i4653.scala -overrideClass.scala - -# repeating on a top level type definition -i18750.scala diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist deleted file mode 100644 index 1cb73da4c2eb..000000000000 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ /dev/null @@ -1,120 +0,0 @@ -i94-nada.scala -i1812.scala -i1867.scala -i3067.scala -t2712-5.scala -t284-pos.scala -t3249 -t3486 -t3612.scala -reference -scala-days-2019-slides -i7048e.scala -i8052.scala -tuple-filter.scala -i7740a.scala -i7740b.scala -i6507b.scala -i12299a.scala -i13871.scala -i15181.scala -i15922.scala -i15926.scala -t5031_2.scala -i16997.scala -i7414.scala -i17588.scala -i9804.scala -i13433.scala -i16649-irrefutable.scala -strict-pattern-bindings-3.0-migration.scala -i17255 -i17735.scala - -# Tree is huge and blows stack for printing Text -i7034.scala - -# Stale symbol: package object scala -seqtype-cycle - -# type of super reference changes due to late addition of Mirror.Singleton -i939.scala -i13332super.scala - -# Match types -i7872.scala -i11236.scala -i11247.scala -i11250 -i9999.scala -8649.scala -12093.scala -9757.scala -9890.scala -13491.scala -7512.scala -i6505.scala -i15158.scala -i15155.scala -i15827.scala -i18211.scala -i20897.scala - -# Opaque type -i5720.scala - -# Tuples -toexproftuple.scala -i7580.scala - -# Nullability -nullable.scala - -# parameter untupling with overloaded functions (see comment in Applications.normArg) -i7757.scala - -# splice type tag dealiased in this reference -i8651b.scala - -# uneliminated @uncheckedVariance after pickling -annot-bootstrap.scala - -# interaction with Scala-2's implicitly -i9793.scala - -# lazy_implicit symbol has different position after pickling -i8182.scala - -# local lifted value in annotation argument has different position after pickling -i2797a - -# Late instantiation of type variable in tryInsertImplicitOnQualifier -# allows to simplify a type that was already computed -i13842.scala - -# Position change under captureChecking -boxmap-paper.scala - -# Function types print differnt after unpickling since test mispredicts Feature.preFundsEnabled -caps-universal.scala - -# GADT cast applied to singleton type difference -i4176-gadt.scala - -# GADT difference -i13974a.scala - -java-inherited-type1 - -# recursion limit exceeded -i7445b.scala - -# more aggresive reduce projection makes a difference -i15525.scala -i19955a.scala -i19955b.scala -i20053b.scala - - -# LTS specific -i21390.TrieMap.scala diff --git a/compiler/test/dotc/pos-test-pickling.excludelist b/compiler/test/dotc/pos-test-pickling.excludelist index 23c79affada0..8f09dc61609b 100644 --- a/compiler/test/dotc/pos-test-pickling.excludelist +++ b/compiler/test/dotc/pos-test-pickling.excludelist @@ -141,3 +141,6 @@ hylolib # typecheckErrors method unpickling i21415.scala + +# LTS specific +i21390.TrieMap.scala diff --git a/compiler/test/dotc/run-test-pickling.blacklist b/compiler/test/dotc/run-test-pickling.blacklist deleted file mode 100644 index 32fa44d0cb20..000000000000 --- a/compiler/test/dotc/run-test-pickling.blacklist +++ /dev/null @@ -1,52 +0,0 @@ -## Many of these tests fail because CompilationTests.pickling does not handle -## tests containing java files correctly - -derive-generic.scala -eff-dependent.scala -enum-java -i5257.scala -i7212 -i7868.scala -i9011.scala -i9473.scala -i13433.scala -i13433b.scala -macros-in-same-project1 -mixin-forwarder-overload -t10889 -t3452d -t3452e -t3452g -t7374 -t8905 -tuple-drop.scala -tuple-ops.scala -tuple-ops.scala -tuple-take.scala -tuple-zip.scala -tuples1.scala -tuples1a.scala -tuples1b.scala -typeCheckErrors.scala -typeclass-derivation-doc-example.scala -typeclass-derivation1.scala -typeclass-derivation2.scala -typeclass-derivation2a.scala -typeclass-derivation2b.scala -typeclass-derivation2c.scala -typeclass-derivation2d.scala -typeclass-derivation3.scala -varargs-abstract -zero-arity-case-class.scala -i12194.scala -i12753 -t6138 -t6138-2 -i12656.scala -trait-static-forwarder -i17255 - -# typecheckErrors method unpickling -typeCheckErrors.scala -i18150.scala - diff --git a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala index 769eaf024862..f8249aebf68c 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala @@ -107,7 +107,7 @@ object HoverProvider: case (symbol, tpe, _) :: _ if symbol.name == nme.selectDynamic || symbol.name == nme.applyDynamic => fallbackToDynamics(path, printer, contentType) - case symbolTpes @ ((symbol, tpe, None) :: _) => + case symbolTpes @ ((symbol, tpe, _) :: _) => val exprTpw = tpe.widenTermRefExpr.deepDealias val hoverString = tpw match @@ -153,21 +153,6 @@ object HoverProvider: case _ => ju.Optional.empty().nn end match - case (_, tpe, Some(namedTupleArg)) :: _ => - val exprTpw = tpe.widenTermRefExpr.deepDealias - printer.expressionType(exprTpw) match - case Some(tpe) => - ju.Optional.of( - new ScalaHover( - expressionType = Some(tpe), - symbolSignature = Some(s"$namedTupleArg: $tpe"), - docstring = None, - forceExpressionType = false, - contextInfo = printer.getUsedRenamesInfo, - contentType = contentType - ) - ).nn - case _ => ju.Optional.empty().nn end match end if end hover @@ -183,7 +168,7 @@ object HoverProvider: case SelectDynamicExtractor(sel, n, name, rest) => def findRefinement(tp: Type): Option[HoverSignature] = tp match - case RefinedType(_, refName, tpe) if (name == refName.toString() || refName.toString() == nme.Fields.toString()) => + case RefinedType(_, refName, tpe) if name == refName.toString() => val resultType = rest match case Select(_, asInstanceOf) :: TypeApply(_, List(tpe)) :: _ if asInstanceOf == nme.asInstanceOfPM => @@ -196,8 +181,7 @@ object HoverProvider: else printer.tpe(resultType) val valOrDef = - if refName.toString() == nme.Fields.toString() then "" - else if n == nme.selectDynamic && !tpe.isInstanceOf[ExprType] + if n == nme.selectDynamic && !tpe.isInstanceOf[ExprType] then "val " else "def " diff --git a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala index a24ed5c7c9e7..dc4fa0446715 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/MetalsInteractive.scala @@ -203,20 +203,6 @@ object MetalsInteractive: case _ => Nil - // Handle select on named tuples - case (Apply(Apply(TypeApply(fun, List(t1, t2)), List(ddef)), List(Literal(Constant(i: Int))))) :: _ - if fun.symbol.exists && fun.symbol.name == nme.apply && - fun.symbol.owner.exists && fun.symbol.owner == getModuleIfDefined("scala.NamedTuple").moduleClass => - def getIndex(t: Tree): Option[Type] = - t.tpe.dealias match - case AppliedType(_, args) => args.get(i) - case _ => None - val name = getIndex(t1) match - case Some(c: ConstantType) => c.value.stringValue - case _ => "" - val tpe = getIndex(t2).getOrElse(NoType) - List((ddef.symbol, tpe, Some(name))) - case path @ head :: tail => if head.symbol.is(Exported) then val sym = head.symbol.sourceSymbol diff --git a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala index ff4c6ec25e27..fab21ffdee0a 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala @@ -504,12 +504,3 @@ class PcDefinitionSuite extends BasePcDefinitionSuite: |val a = MyIntOut(1).un@@even |""".stripMargin, ) - - @Test def `named-tuples` = - check( - """|import scala.language.experimental.namedTuples - | - |val <> = (name = "Bob", age = 42, height = 1.9d) - |val foo_name = foo.na@@me - |""".stripMargin - ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala index 5e20045babfb..6f682139506e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -718,32 +718,3 @@ class HoverTermSuite extends BaseHoverSuite: """def ???: Nothing""".stripMargin.hover ) - @Test def `named-tuples`: Unit = - check( - """import scala.language.experimental.namedTuples - | - |val foo = (name = "Bob", age = 42, height = 1.9d) - |val foo_name = foo.na@@me - |""".stripMargin, - "name: String".hover - ) - - @Test def `named-tuples2`: Unit = - check( - """|import scala.language.experimental.namedTuples - | - |import NamedTuple.* - | - |class NamedTupleSelectable extends Selectable { - | type Fields <: AnyNamedTuple - | def selectDynamic(name: String): Any = ??? - |} - | - |val person = new NamedTupleSelectable { - | type Fields = (name: String, city: String) - |} - | - |val person_name = person.na@@me - |""".stripMargin, - "name: String".hover - ) diff --git a/tests/pos-custom-args/captures/setup/a_1.scala b/tests/pos-custom-args/captures/setup/a_1.scala deleted file mode 100644 index 21afde8be3ea..000000000000 --- a/tests/pos-custom-args/captures/setup/a_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -// a.scala -import language.experimental.captureChecking -import scala.caps.CapSet - -trait A: - def f[C^](x: AnyRef^{C^}): Unit diff --git a/tests/pos-custom-args/captures/setup/b_1.scala b/tests/pos-custom-args/captures/setup/b_1.scala deleted file mode 100644 index d5ba925970ba..000000000000 --- a/tests/pos-custom-args/captures/setup/b_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -import language.experimental.captureChecking -import scala.caps.CapSet - -class B extends A: - def f[C^](x: AnyRef^{C^}): Unit = ??? diff --git a/tests/pos-custom-args/captures/setup/b_2.scala b/tests/pos-custom-args/captures/setup/b_2.scala deleted file mode 100644 index d5ba925970ba..000000000000 --- a/tests/pos-custom-args/captures/setup/b_2.scala +++ /dev/null @@ -1,5 +0,0 @@ -import language.experimental.captureChecking -import scala.caps.CapSet - -class B extends A: - def f[C^](x: AnyRef^{C^}): Unit = ??? diff --git a/tests/pos/i21931.scala b/tests/pos/i21931.scala new file mode 100644 index 000000000000..6765768874af --- /dev/null +++ b/tests/pos/i21931.scala @@ -0,0 +1,13 @@ +def f() = + val NotFound: Char = 'a' + class crashing() { + class issue() { + NotFound + } + class Module() { + val obligatory = + class anonIssue() { + issue() + } + } + }