A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://scala-lang.org/api/3.x/scala/annotation/init$$widen.html below:

widen

scala.annotation.init.widen

Widen the abstract value of the argument so that its height is below the specified height.

It can be used to mark method or constructor arguments, as the following example shows:

class A(x: Int): def square(): Int = x*x

class C(val a: A)

object B: val a = build(new C(new A(10)): @widen(2)) // <-- usage

 def build(c: C) = new A(c.a.square())           // calling methods on parameter

By default, method and constructor arguments are widened to height 1. In the code above, without using @widen(2) we will have the abstract value C(a = Cold) for the argument c of the method build. Consequently, the checker will issue a warning for the method call c.a.square() because it is forbidden to call methods or access fields on cold values.

Attributes
Experimental
true
Source
init.scala
Graph
Supertypes

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4