Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Aug 13, 2014

RefChecks are now in, ad quite a few things had to be done to make it happen.

This PR depends on #161 and #162. They should be reviewed and committed first.

review by @DarkDimius and generally up fro grabs.

odersky added 30 commits August 3, 2014 20:43
Added decorators for symbols that can query specific
annotations and annotation arguments (for now, -deprecated
and -migration are added)
Added method to traverse all parts of a type.
Two improvements to TreeTransform:

1) Added transformOther functionality which handles trees not handled by other parts
2) Passes down Mode.Pattern in the context when in a pattern.

TreeTransform no longer normalizes unknown trees but passes them to transformOther.
The former Companions phase has been renamed to FirstTransform. It now performs the
following optimizations:
 - adds companion objects (this was done before)
 - other normalizations that were formally done in TreeTransform,
 - rewrite native methods to stubs (this was formally done in RefChecks)
Cycles are now detected early, when an info is first completed.
Legal, f-bounded cycles are broken by a LazyRef, which will construct
its type lazily. This makes checkBounds validation of AppliedTypeTrees work
(in FirstTransform). Formerly, this stackoverflowed despite the laziness
precautions in findMember.

Todo: Do the same for class files coming from Java and Scala 2.x.
Insert LazyRefs to break cycles for F-bounded types that
are unpickled or read from Java signatures.
Now that F-bunded types are treated more robustly, we can check bounds for
non-emptyness during Typer.

This unvealed one wrong test (wonder how that passed scalac?), which got
moved to neg.
Statements are now transformed with the transform returned by prepareStats,
analogoys to the other prepare methods.
This is still disabled, because the prepare machinery in transform
does not work yet. Concretely, prepare ops need to return a new TreeTransform
but that tree transform has an undefined phaase id.

We need some architectural changes to disentangle transforms from phases.
... so that it can be combined with TreeTransform in a trait composition
in a future dientanglement of TreeTransforms and Phases.
Would be flagged as unimplemented members in refChecks otherwise
TreeTransforms are no longer phases. This allows to generate
new transforms in prepare... methods without running into the
problem that thee new transforms are undefined as phases.

It also makes for a cleaner separation of concerns.
Should have lazy flag set, otherwise forward reference checking would
fail for modules.

Note: LazyVals needed to be disabled because it also should transform
module vals, but didn't do this so far because it only tested the Lazy flag.
It turned out the module val transformation exposed some bugs in lazy vals
in that LazyVals creates symbols as a side effect and enters them into scopes.
Such mutations are allowed onyl in very specific cases (essentially only for local
throw-away scopes).
Scopes are also used in overriding pairs, and there multiple types with
the same name can be entered in a scope. So the assert to the contrary
should be limited to typechecking only.
Eta-lifting picked some arbitrary base type. It turned out that i94-nada failed once we add
a product trait to case classes (in the next commit) because Eta-Kifting picked Product
as the base type, even though the target type was bounded by Monad. We now change the scheme
so that the target type is included in the lifting, in order to avoid that we lift to
useless types.
Case classes with arity <= 1 now also get a ProductN parent trait.
This is necessary because we inherit productArity and Element methods
in case classes from the ProdictN trait.

Needed to add Product0 for this, which is not defined in Scala2.x.
After erasure, former Any members become Object members.

Also, fixed some typos and added some TODOs on addBridges.
asInstance/isInstance/ensureConforms/and/or.

They replace some former "mk..." methods.
Also renamed Boolean_and/or to _&&/||, to make it conform
to naming convention for other Definition operators.
RefChecks needs both methods.
New phase for Synthetic Method generation. Scala 2.x did it in Typer, but
it's cleaner to do it in a separate phase.
If a TypeRef with an expanded name is an alias type, print the alias instead.
Now that caes classes always inherit from ProductX, we can avoid
the special case. (We need to define _1 anyway to implement Product1).
(1) set position of companion object def
(2) companions of case classes taking multiple parameter lists do not inherit from
    a function type (reason: we can't straightforwardly converyt a curried method
    with multiple parameter lists to a function value).
For overriding checks we need a concept where a val can match a def.
Normal matches does not provide this.
Previously it did this only sometimes. Now it always prefers
concrete over deferred unless the deferred info is a proper subtype
of the concrete info.
Packages should always have a single denotation, which is invariant for all transformations.
Package members should always be entered in the first phase, and should never be entered
after a given phase.

This reflects the fact that package members correspond to classfiles. Once you create a classfile, it
stays around and is available from the start of the next run. Also, we need to prevent multiple
denotation versions of packages from hanging on to stale symbols. It would not be enough to replace
a package member by a newly compiled one; if packages had multiple denotations we'd have to do this
for all of them.
Should be `base`, was the class enclosing the definition.
RefChecks is now enabled. Some of the tests had to be fixed to be refchecks-correct.
@DarkDimius DarkDimius merged commit 34f73de into scala:master Oct 11, 2014
@allanrenucci allanrenucci deleted the transform/refchecks branch December 14, 2017 19:25
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "Fix inline reduction for CaseDef guards with asInstanceOf" to 3.3 LTS
Gedochao added a commit to Gedochao/dotty that referenced this pull request Sep 29, 2025
Fix val parameter override problem
v0.2.1 -- fix potential IDB API issue
dep: update a whole bunch of things (scala#71)

This pr updates the following:

  - various dependencies to the latest
  - adds in dependabot
  - updates java and checkout actions
  - updates ammonite scripts and uses new ammonite in CI
  - updates mill to the latest 0.10.5
  - bumps scalajs to 1.x
  - corrects repo location in pomSettings
Merge pull request scala#4238 from armanbilge/issue/4229

Build docs on 2.13
Merge pull request scala#350 from typelevel/update/sbt-typelevel-0.4.13

Update sbt-typelevel to 0.4.13
Merge pull request scala#187 from typelevel/update/sbt-typelevel-0.4.13

Update sbt-typelevel to 0.4.13
Merge pull request scala#318 from scala-steward/update/sbt-typelevel-0.4.3

Update sbt-typelevel, sbt-typelevel-site to 0.4.3
fix http4s output encoding to UTF-8 (scala#900)

support scala 3.0.0
Migrate to sbt slash syntax
Merge pull request scala#2951 from pchlupacek/patch-1

Update adopters.md
Adapt to new restrictions in fewerBraces
wip: cleanups
Reduce program size in one of the tests to decrease the chance of stack overflow.
v4.6.0
Update scalafmt-core to 3.4.0
Remove import suggestions from assertions
Clarify the unit of proc().call() 'timeout' parameter (scala#107)

Pull request: com-lihaoyi/os-lib#107
Setting version to 2.4.1-SNAPSHOT
Update auxlib, javalib, junit-plugin, ... to 0.4.3
Update serialization base64 for new lazy vals
Merge pull request scala#616 from SethTisue/enable-scala-3-publishing

Disable ExpectationsSpecs message tests
Fix test for change in union type inference
empty
Merge pull request scala#380 from scala-steward/update/sbt-typelevel-0.4.3

Update sbt-typelevel to 0.4.3
Update scalafmt-core to 3.7.12 (scala#163)

Co-authored-by: typelevel-steward[bot] <106827141+typelevel-steward[bot]@users.noreply.github.com>
test: use the same line numbers in the location spec

regardless of the scala compiler version
Disable buggy test

See scala#16390
New reference compiler is Scala 2.13.12
deps: update a bunch of things (scala#395)

* deps: update a bunch of things

This updates the following:

  - make sure Mill is on the latest 0.10.5
  - drops support for scalajs 0.x
  - bumps to the latest scala patch versions
  - bumps to the latest scalaJS and scala native
  - bumps to 0.8.0 of utest
  - adds in dependabot
  - adds in cross testing jdk for 8 and 17
  - bumps version of checkout and java actions

* refactor: restructure build to actually build

* fix: make mima happy by updating
Merge pull request scala#264 from scala-steward/update/test-interface-0.4.7

Update test-interface to 0.4.7
Merge pull request scala#183 from scala-steward/update/auxlib-0.4.3

Update auxlib, javalib, nativelib, nscplugin, ... to 0.4.3
Revert "Fix tests to work with changes after scala#15569"

This reverts commit 912b4f887912792202aa76e93fd19e63bd62f3bc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants