Skip to content

Backport "Fix a REPL bad symbolic reference" to LTS #20939

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

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
38653b1
fix(#16458): regression in xml syntax parsing
i10416 Jan 23, 2024
4e69d79
improve: just use content_LT to fix 16458
i10416 Jan 24, 2024
2489171
tidy: use run test instead of compile test
i10416 Jan 24, 2024
4631efc
Switch to Java 17 in the CI
WojciechMazur Jul 1, 2024
acc8ef6
Improve -Xprint-suspension message
nicolasstucki Feb 14, 2024
5146353
Add regression test
nicolasstucki Feb 14, 2024
0d70764
update documentation for running scalajs tests with update checkfiles
aherlihy Feb 8, 2024
4694863
Add explanation for NotClassType error message
aherlihy Feb 6, 2024
beef369
Prefer extensions over conversions for member selection
odersky Feb 17, 2024
0c3717f
[regression] Publish nightly releases and releases using Java 8 (#19722)
hamzaremmal Feb 19, 2024
c266bee
Add regression test for #19087 (#19726)
mbovel Feb 19, 2024
9059b33
Tweak parameter accessor scheme
odersky Feb 17, 2024
fd844b7
bugfix: Choose correct signature is signatureHelp for overloaded methods
jkciesluk Feb 16, 2024
7648f96
Fix #19402: improved parsing of given paramiters with absence of usin…
OlgaMazhara-TomTom Feb 17, 2024
6c8d82a
Update scala-js-dom
JD557 Feb 11, 2024
ed7a0ea
Load search bar if defined in the query param
JD557 Feb 11, 2024
9dc1d97
Remove test requiring publicInBinary annotation from LTS backport
WojciechMazur Jul 1, 2024
0d6dab5
remove implementation from asInstanceOf
robstoll Feb 21, 2024
ca6b2c0
improvement: Replace synthetic decorations with inlay hints
jkciesluk Feb 21, 2024
b09d745
reproduce the issue
bishabosha Feb 14, 2024
739cebb
do not look in companion in javaFindMember in typedSelect
bishabosha Feb 16, 2024
cda3388
Widen prefix in findRef of class from Java sources.
bishabosha Feb 16, 2024
7d35282
also cook the tree of a java raw type
WojciechMazur Jul 1, 2024
f49f36a
In Java sources, allow a non-stable prefix for a class parent.
bishabosha Feb 21, 2024
c190fc8
skip test on scala-js
bishabosha Feb 22, 2024
90835e6
Remove not-applicable sbt-test/pipelining from LTS
WojciechMazur Jul 1, 2024
0c60d27
test: add test for #19762
i10416 Feb 24, 2024
e8f46ba
Attempt implicit search for old style `implicit` parameters
EugeneFlesselle Feb 19, 2024
7d59a35
Add a new test for selection range on function parameters
natsukagami Feb 24, 2024
c3454bc
Add selection range for a parameter list in a function/method
natsukagami Feb 24, 2024
421a3d1
Bump JLine to 3.19.0 -> 3.24.1
hamzaremmal Feb 20, 2024
6ec5acd
Bump sbt from 1.9.7 to 1.9.9
hamzaremmal Feb 24, 2024
de16497
Update Coursier test
hamzaremmal Feb 25, 2024
15c3f9c
Bump JLine to 3.24.1-> 3.25.1
hamzaremmal Feb 26, 2024
b70354e
Test case for REPL bad symbolic reference
dwijnand Feb 21, 2024
858f974
Add a test case which still fails
dwijnand Feb 21, 2024
3d3d8aa
Avoid losing the symbols denotation on update
dwijnand Feb 23, 2024
e916b4a
Some tweaks to denotation updates
odersky Feb 26, 2024
ddfc4d3
Avoid setting lastDenot to NoDenotation in the forward reference scen…
odersky Feb 26, 2024
deaaf0d
Update compiler/src/dotty/tools/dotc/core/Symbols.scala
odersky Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
test_non_bootstrapped:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -65,8 +65,8 @@ jobs:
&& github.repository == 'scala/scala3'
)"
steps:
- name: Set JDK 16 as default
run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH

## Workaround for https://github.com/actions/runner/issues/2033 (See https://github.com/scala/scala3/pull/19720)
- name: Reset existing repo
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
test:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -119,8 +119,8 @@ jobs:
)"

steps:
- name: Set JDK 16 as default
run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH

- name: Reset existing repo
run: |
Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:
name: MiMa
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -248,6 +248,9 @@ jobs:
&& github.repository == 'scala/scala3'
)"
steps:
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand All @@ -272,7 +275,7 @@ jobs:
community_build_a:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -293,6 +296,8 @@ jobs:
)"

steps:
- name: Set JDK 8 as default
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand Down Expand Up @@ -324,7 +329,7 @@ jobs:
community_build_b:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -345,6 +350,8 @@ jobs:
)"

steps:
- name: Set JDK 8 as default
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand Down Expand Up @@ -376,7 +383,7 @@ jobs:
community_build_c:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2020-11-19
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -397,6 +404,8 @@ jobs:
)"

steps:
- name: Set JDK 8 as default
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand Down Expand Up @@ -428,7 +437,7 @@ jobs:
test_sbt:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -447,6 +456,9 @@ jobs:
)"

steps:
- name: Set JDK 17 as default
run: echo "/usr/lib/jvm/java-17-openjdk-amd64/bin" >> $GITHUB_PATH

- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand All @@ -470,7 +482,7 @@ jobs:
test_java8:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand Down Expand Up @@ -526,7 +538,7 @@ jobs:
publish_nightly:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -542,6 +554,8 @@ jobs:
SONATYPE_USER: ${{ secrets.SONATYPE_USER_ORGSCALALANG }}

steps:
- name: Set JDK 8 as default
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand Down Expand Up @@ -579,7 +593,7 @@ jobs:
nightly_documentation:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand Down Expand Up @@ -633,7 +647,7 @@ jobs:
contents: write # for actions/create-release to create a release
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
options: --cpu-shares 4096
volumes:
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
Expand All @@ -651,6 +665,8 @@ jobs:
SONATYPE_USER: ${{ secrets.SONATYPE_USER_ORGSCALALANG }}

steps:
- name: Set JDK 8 as default
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
- name: Reset existing repo
run: |
git config --global --add safe.directory /__w/scala3/scala3
Expand Down Expand Up @@ -723,7 +739,7 @@ jobs:
open_issue_on_failure:
runs-on: [self-hosted, Linux]
container:
image: lampepfl/dotty:2021-03-22
image: lampepfl/dotty:2023-11-07
needs: [nightly_documentation, test_windows_full]
# The `failure()` expression is true iff at least one of the dependencies
# of this job (including transitive dependencies) has failed.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
|"""
val enableXprintSuspensionHint =
if ctx.settings.XprintSuspension.value then ""
else "\n\nCompiling with -Xprint-suspension gives more information."
else "\n\nCompile with -Xprint-suspension for information."
report.error(em"""Cyclic macro dependencies $where
|Compilation stopped since no further progress can be made.
|
Expand Down
15 changes: 12 additions & 3 deletions compiler/src/dotty/tools/dotc/core/ContextOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ object ContextOps:
if (elem.name == name) return elem.sym.denot // return self
}
val pre = ctx.owner.thisType
if ctx.isJava then javaFindMember(name, pre, required, excluded)
if ctx.isJava then
// Note: I didn't verify if there exists a code path that would require `lookInCompanion = true`,
// it is just to preserve the original behavior.
javaFindMember(name, pre, lookInCompanion = true, required, excluded)
else pre.findMember(name, pre, required, excluded)
}
else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext.
Expand All @@ -43,7 +46,13 @@ object ContextOps:
ctx.scope.denotsNamed(name).filterWithFlags(required, excluded).toDenot(NoPrefix)
}

final def javaFindMember(name: Name, pre: Type, required: FlagSet = EmptyFlags, excluded: FlagSet = EmptyFlags): Denotation =
/** Look in the prefix with Java semantics.
* @param lookInCompanion If true, try in the companion class of a module as a fallback.
* Note: originally this was used to type Select nodes in Java code,
* but that is no longer the case.
* It is preserved in case it is necessary for denotNamed, but this is unverified.
*/
final def javaFindMember(name: Name, pre: Type, lookInCompanion: Boolean, required: FlagSet = EmptyFlags, excluded: FlagSet = EmptyFlags): Denotation =
assert(ctx.isJava)
inContext(ctx) {

Expand All @@ -53,7 +62,7 @@ object ContextOps:
val directSearch = pre.findMember(name, pre, required, excluded)

// 2. Try to search in companion class if current is an object.
def searchCompanionClass = if preSym.is(Flags.Module) then
def searchCompanionClass = if lookInCompanion && preSym.is(Flags.Module) then
preSym.companionClass.thisType.findMember(name, pre, required, excluded)
else NoDenotation

Expand Down
7 changes: 7 additions & 0 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,13 @@ object SymDenotations {
def namedType(using Context): NamedType =
if (isType) typeRef else termRef

/** Like typeRef, but the prefix is widened.
*
* See tests/neg/i19619/Test.scala
*/
def javaTypeRef(using Context) =
TypeRef(maybeOwner.reachablePrefix.widen, symbol)

/** Like typeRef, but objects in the prefix are represented by their singleton type,
* this means we output `pre.O.member` rather than `pre.O$.this.member`.
*
Expand Down
19 changes: 15 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,28 @@ object Symbols extends SymUtils {
}

private def computeDenot(lastd: SymDenotation)(using Context): SymDenotation = {
// Written that way so that it comes in at 32 bytes and is therefore inlineable for
// the JIT (reputedly, cutoff is at 35 bytes)
util.Stats.record("Symbol.computeDenot")
val now = ctx.period
checkedPeriod = now
if (lastd.validFor contains now) lastd else recomputeDenot(lastd)
if lastd.validFor.contains(now) then lastd else recomputeDenot(lastd)
}

/** Overridden in NoSymbol */
protected def recomputeDenot(lastd: SymDenotation)(using Context): SymDenotation = {
util.Stats.record("Symbol.recomputeDenot")
val newd = lastd.current.asInstanceOf[SymDenotation]
lastDenot = newd
if newd.exists || lastd.initial.validFor.firstPhaseId <= ctx.phaseId then
lastDenot = newd
else
// We are trying to bring forward a symbol that is defined only at a later phase
// (typically, a nested Java class, invisible before erasure).
// In that case, keep lastDenot as it was and set the checked period to lastDenot's
// previous validity, which means we will try another bring forward when the symbol
// is referenced at a later phase. Otherwise we'd get stuck on NoDenotation here.
// See #15562 and test i15562b in ReplCompilerTests
checkedPeriod = lastd.validFor
newd
}

Expand Down Expand Up @@ -764,7 +775,7 @@ object Symbols extends SymUtils {
cls: ClassSymbol,
name: TermName = nme.WILDCARD,
selfInfo: Type = NoType)(using Context): TermSymbol =
newSymbol(cls, name, SelfSymFlags, selfInfo orElse cls.classInfo.selfType, coord = cls.coord)
newSymbol(cls, name, SelfSymFlags, selfInfo.orElse(cls.classInfo.selfType), coord = cls.coord)

/** Create new type parameters with given owner, names, and flags.
* @param boundsFn A function that, given type refs to the newly created
Expand Down Expand Up @@ -931,7 +942,7 @@ object Symbols extends SymUtils {
*/
def getPackageClassIfDefined(path: PreName)(using Context): Symbol =
staticRef(path.toTypeName, isPackage = true, generateStubs = false)
.disambiguate(_ is PackageClass).symbol
.disambiguate(_.is(PackageClass)).symbol

def requiredModule(path: PreName)(using Context): TermSymbol = {
val name = path.toTermName
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3958,7 +3958,7 @@ object Parsers {
val tparams = typeParamClauseOpt(ParamOwner.Given)
newLineOpt()
val vparamss =
if in.token == LPAREN && in.lookahead.isIdent(nme.using)
if in.token == LPAREN && (in.lookahead.isIdent(nme.using) || name != EmptyTermName)
then termParamClauses(ParamOwner.Given)
else Nil
newLinesOpt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ object MarkupParsers {
while {
xSpaceOpt()
nextch()
ts.append(element)
content_LT(ts)
charComingAfter(xSpaceOpt()) == '<'
} do ()
handle.makeXMLseq(Span(start, curOffset, start), ts)
Expand Down
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ extends NotFoundMsg(MissingIdentID) {
}
}

class TypeMismatch(found: Type, expected: Type, inTree: Option[untpd.Tree], addenda: => String*)(using Context)
class TypeMismatch(val found: Type, expected: Type, inTree: Option[untpd.Tree], addenda: => String*)(using Context)
extends TypeMismatchMsg(found, expected)(TypeMismatchID):

def msg(using Context) =
Expand Down Expand Up @@ -2749,7 +2749,11 @@ extends SyntaxMsg(TargetNameOnTopLevelClassID):
class NotClassType(tp: Type)(using Context)
extends TypeMsg(NotClassTypeID), ShowMatchTrace(tp):
def msg(using Context) = i"$tp is not a class type"
def explain(using Context) = ""
def explain(using Context) =
i"""A class type includes classes and traits in a specific order. Defining a class, even an anonymous class,
|requires specifying a linearization order for the traits it extends. For example, `A & B` is not a class type
|because it doesn't specify which trait takes precedence, A or B. For more information about class types, please see the Scala Language Specification.
|Class types also can't have refinements."""

class NotConstant(suffix: String, tp: Type)(using Context)
extends TypeMsg(NotConstantID), ShowMatchTrace(tp):
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
* This info is used in phase ParamForwarding
*/
private def forwardParamAccessors(impl: Template)(using Context): Unit = impl.parents match
case superCall @ Apply(fn, superArgs) :: _ if superArgs.nonEmpty =>
case superCall @ Apply(fn, superArgs) :: _
if superArgs.nonEmpty && fn.symbol.isPrimaryConstructor =>
fn.tpe.widen match
case MethodType(superParamNames) =>
for case stat: ValDef <- impl.body do
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ trait Applications extends Compatibility {
defaultArg.tpe.widen match
case _: MethodOrPoly if testOnly => matchArgs(args1, formals1, n + 1)
case _ => matchArgs(args1, addTyped(treeToArg(defaultArg)), n + 1)
else if methodType.isContextualMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
else if methodType.isImplicitMethod && ctx.mode.is(Mode.ImplicitsEnabled) then
matchArgs(args1, addTyped(treeToArg(implicitArg)), n + 1)
else
missingArg(n)
Expand Down
Loading