Skip to content

new line after rule heading #4174

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

Merged
merged 2 commits into from
Mar 24, 2018
Merged
Changes from 1 commit
Commits
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
12 changes: 12 additions & 0 deletions docs/docs/reference/erased-terms.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Rules
-----

1) The `erased` modifier can appear:

* At the start of a parameter block of a method, function or class
* In a method definition
* In a `val` definition (but not `lazy val` or `var`)
Expand All @@ -164,11 +165,15 @@ def h(x: erased Int => Int) = ...
class K(erased x: Int) { ... }
```


Copy link
Contributor

@Blaisorblade Blaisorblade Mar 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the extra line before also required (here and below)? I thought not.

Copy link
Contributor Author

@robstoll robstoll Mar 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, its not but I figured it reads better in the raw version . The fix @allanrenucci provides reads even better IMO, yet I don't know if it is going to fix the initial problem.

2) A reference to an `erased` definition can only be used

* Inside the expression of argument to an `erased` parameter
* Inside the body of an `erased` `val` or `def`


3) Functions

* `(erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R`
* `(implicit erased x1: T1, x2: T2, ..., xN: TN) => y : (implicit erased T1, T2, ..., TN) => R`
* `implicit erased T1 => R <:< erased T1 => R`
Expand All @@ -177,20 +182,27 @@ class K(erased x: Int) { ... }

Note that there is no subtype relation between `erased T => R` and `T => R` (or `implicit erased T => R` and `implicit T => R`)


4) Eta expansion

if `def f(erased x: T): U` then `f: (erased T) => U`.


5) Erasure Semantics

* All `erased` paramters are removed from the function
* All argument to `erased` paramters are not passed to the function
* All `erased` definitions are removed
* All `(erased T1, T2, ..., TN) => R` and `(implicit erased T1, T2, ..., TN) => R` become `() => R`


6) Overloading

Method with `erased` parameters will follow the normal overloading constraints after erasure.


7) Overriding

* Member definitions overidding each other must both be `erased` or not be `erased`
* `def foo(x: T): U` cannot be overriden by `def foo(erased x: T): U` an viceversa