Spec2.8Chap7a

第 7 章 暗黙のパラメータとビュー (Implicit Parameters and Views)



7.1 implicit 修飾子 (The Implicit Modifier)

構文:

   LocalModifier    ::= 'implicit'
   ParamClauses     ::= {ParamClause} [nl] '(' 'implicit' Params ')'

Template members and parameters labeled with an implicit modifier can be passed to implicit parameters (§7.2) and can be used as implicit conversions called views (§7.3). The implicit modifier is illegal for all type members, as well as for top-level (§9.2) objects .

implicit 修飾子が印されたテンプレートのメンバーとパラメータを暗黙のパラメータ (§7.2) へ渡すことができ、 ビュー(§7.3)と呼ばれる暗黙の変換を使えます。 implicit 修飾子は、トップレベル (§9.2)のオブジェクトに対してと同様に、 すべての型メンバーに対しても不正です。


Example 7.1.1

The following code defines an abstract class of monoids and two concrete implementations, StringMonoid and IntMonoid . The two implementations are marked implicit .

次のコードは monoids の抽象クラスと 2 つの具象実装、StringMonoid と IntMonoid を定義しています。 2 つの実装は implicit とマークされています。

   abstract class Monoid[A] extends SemiGroup[A] {
     def unit: A
     def add(x: A, y: A): A
   }
   object Monoids {
     implicit object stringMonoid extends Monoid[String] {
       def add(x: String, y: String): String = x.concat(y)
       def unit: String = ""
     }
     implicit object intMonoid extends Monoid[Int] {
       def add(x: Int, y: Int): Int = x + y
       def unit: Int = 0
     }
   }



7.2 暗黙のパラメータ (Implicit Parameters)

An implicit parameter list (implicit p1,...,pn) of a method marks the parameters p1,...,pn as implicit . A method or constructor can have only one implicit parameter list, and it must be the last parameter list given .

メソッドの暗黙のパラメータリスト(implicit p1,...,pn) は、 パラメータ p1,...,pn を implicit とマークします。 メソッドあるいはコンストラクタは、 ただ 1 つの暗黙のパラメータリストを持つことができ、 それは与えられた最後のパラメータリストでなければなりません。

A method with implicit parameters can be applied to arguments just like a normal method . In this case the implicit label has no effect . However, if such a method misses arguments for its implicit parameters, such arguments will be automatically provided .

暗黙のパラメータをもつメソッドは、通常のメソッドとまったく同じように 引数に適用されます。 この場合、implicit ラベルは効果を持ちません。 しかし、もしメソッドがその暗黙のパラメータに対する引数を失っているなら、 そのような引数は自動的に供給されます。

The actual arguments that are eligible to be passed to an implicit parameter of type T fall into two categories . First, eligible are all identifiers x that can be accessed at the point of the method call without a prefix and that denote an implicit definition (§7.1) or an implicit parameter . An eligible identifier may thus be a local name, or a member of an enclosing template, or it may be have been made accessible without a prefix through an import clause (§4.7). If there are no eligible identifiers under this rule, then, second, eligible are also all implicit members of some object that belongs to the implicit scope of the implicit parameter's type, T .

型 T の暗黙のパラメータに渡すに適した実際の引数は、2 つのカテゴリに分けられます。 1つめは、メソッド呼び出しの時点でアクセスできる、前置子のつかない、 implicit 定義(§7.1) あるいは暗黙のパラメータを表す、 すべての識別子 x が適しています。 適した識別子は、このようにローカル名、あるいは、 取り囲むテンプレートのメンバー、あるいは、インポート節 (§4.7) を通して前置子なしでアクセス可能になっているものです。 もしこの規則の下で適した識別子がないなら、2つめは、 暗黙のパラメータの型 T の暗黙のスコープに入っている、 あるオブジェクトのすべての暗黙のメンバーも適しています。

The implicit scope of a type T consists of all companion modules (§5.4) of classes that are associated with the implicit parameter's type . Here, we say a class C is associated with a type T , if it is a base class (§5.1.2) of some part of T . The parts of a type T are:

型 T の 暗黙のスコープ は、 暗黙のパラメータの型に随伴するクラスのすべてのコンパニオンモジュール (§5.4)から成ります。 ここで、クラス C が型 T に 随伴する とは、 それが T のある部分の基底クラス (§5.1.2) である場合を言います。 型 T の部分とは、次です。

  • if T is a compound type T1 with ... with Tn , the union of the parts of T1,...,Tn , as well as T itself,
  • if T is a parameterized type S[T1,...,Tn], the union of the parts of S and T1,...,Tn ,
  • if T is a singleton type p.type, the parts of the type of p,
  • if T is a type projection S#U , the parts of S as well as T itself,
  • in all other cases, just T itself .
  • もし T が複合型 T1 with ... with Tn なら、T 自身と同様、T1,...,Tn の部分の和集合。
  • もし T がパラメータ化された型 S[T1,...,Tn] なら、S および T1,...,Tn の部分の和集合。
  • もし T がシングルトン型 p.type なら、p の型の部分。
  • もし T が型投影 S#U なら、T 自身と同様、S の部分。
  • 他のすべての場合、T それ自身。

If there are several eligible arguments which match the implicit parameter's type, a most specific one will be chosen using the rules of static overloading resolution (§6.26.3). If the parameter has a default argument and no implicit argument can be found the default argument is used .

もし暗黙のパラメータの型と一致する適した引数が複数あるなら、 最も特化したものが静的なオーバーロード解決の規則 (§6.26.3)を使って選ばれます。 もしパラメータがデフォルト引数を持っていて、 暗黙の引数がみつからないなら、デフォルト引数が使われます。


Example 7.2.1

Assuming the classes from Example 7.1.1, here is a method which computes the sum of a list of elements using the monoid's add and unit operations .

Example 7.1.1 のクラスを仮定します。次は、monoid の add と unit 操作を使って、リストの要素の合計を計算するメソッドです。

 def sum[A](xs: List[A])(implicit m: Monoid[A]): A =
   if (xs.isEmpty) m.unit
   else m.add(xs.head, sum(xs.tail))

The monoid in question is marked as an implicit parameter, and can therefore be inferred based on the type of the list . Consider for instance the call

問題の monoid は暗黙のパラメータとしてマークされており、 したがってリストの型に基づいて推論されます。 たとえば次のインスタンス呼び出しを考えます。

   sum(List(1, 2, 3))

in a context where stringMonoid and intMonoid are visible . We know that the formal type parameter a of sum needs to be instantiated to Int . The only eligible object which matches the implicit formal parameter type Monoid[Int] is intMonoid so this object will be passed as implicit parameter .

This discussion also shows that implicit parameters are inferred after any type arguments are inferred (§6.26.4) .

これは stringMonoid と intMonoid が見えているコンテキスト中にあるものとします。 我々は、sum の形式上の型パラメータ a が Int にインスタンス化される必要があることを知っています。 暗黙の形式上のパラメータ型 Monoid[Int]とマッチする 唯一の適したオブジェクトは intMonoid です。 ですからこのオブジェクトは暗黙のパラメータとして渡されます。

この議論は、すべての型引数が推論された (§6.26.4)後で、 暗黙のパラメータが推論されることも示しています。

Implicit methods can themselves have implicit parameters . An example is the following method from module scala.List, which injects lists into the scala.Ordered class, provided the element type of the list is also convertible to this type .

暗黙のメソッドは、それ自身暗黙のパラメータを持てます。 1つの例は次のメソッドで、これは scala.Ordered クラスにリストを注入 (inject)するモジュール scala.List にあります。 リストの要素型もこの型に互換であるとします。

   implicit def list2ordered[A](x: List[A])
     (implicit elem2ordered: A => Ordered[A]): Ordered[List[A]] =
   ...

さらに加えて、次のメソッドが Ordered クラスに整数を注入すると仮定します。

   implicit def int2ordered(x: Int): Ordered[Int]

そうすると、順序づけられたリスト(ordered list)上に ソートメソッドを 定義できます:

   def sort[A](xs: List[A])(implicit a2ordered: A => Ordered[A]) = ...

次のように、整数のリストのリスト yss: List[List[Int]] にソートを適用できます:

   sort(yss)

上記の呼び出しは、2 重にネストした暗黙の引数を渡すことで完成します。:

   sort(yss)(xs: List[Int] => list2ordered[Int](xs)(int2ordered))

The possibility of passing implicit arguments to implicit arguments raises the possibility of an infinite recursion . For instance, one might try to define the following method, which injects every type into the Ordered class:

暗黙の引数に暗黙の引数を渡せることは、無限再帰を引き起こす可能性があります。 例えば、 すべての 型を Ordered クラスに注入する、 次のメソッドを定義しようとするかもしれません。:

   implicit def magic[A](x: A)
     (implicit a2ordered: A => Ordered[A]): Ordered[A] =
     a2ordered(x)

Now, if one tried to apply sort to an argument arg of a type that did not have another injection into the Ordered class, one would obtain an infinite expansion:

ここで Ordered クラスへの他の注入を持っていない型の引数 arg に、 ソートを適用しようすると無限展開になるでしょう:

   sort(arg)(x => magic(x)(x => magic(x)(x => ... )))

To prevent such infinite expansions, the compiler keeps track of a stack of "open implicit types" for which implicit arguments are currently being searched . Whenever an implicit argument for type T is searched, the "core type" of T is added to the stack . Here, the core type of T is T with aliases expanded, top-level type annotations (§11) and refinements (§3.2.7) removed, and occurrences of top-level existentially bound variables replaced by their upper bounds . The core type is removed from the stack once the search for the implicit argument either definitely fails or succeeds . Everytime a core type is added to the stack, it is checked that this type does not dominate any of the other types in the set .

そのような無限の展開を防ぐために、コンパイラは、 現在検索されている暗黙の引数に関する「オープンな暗黙型」のスタックを追跡します。 型 T に対する暗黙の引数を検索するときはいつでも、 T の「コア型」がスタックに加えられます。 ここで T の コア型 とは、拡張されたエイリアス、 削除されたトップレベルの型アノテーション (§11) と細別 (§3.2.7)、 それらの上限境界で置き換えられたトップレベルの存在的に束縛された変数の出現 などを備えた T です。 コア型は暗黙の引数探索が確実に失敗あるいは成功するとすぐに スタックから取り除かれます。 コア型がスタックに加えられるたびに、 その型が集合中の他のいずれの型もドミネートしないことがチェックされます。

Here, a core type T dominates a type U if T is equivalent (§3.5.1) to U , or if the toplevel type constructors of T and U have a common element and T is more complex than U .

ここで、コア型 T が型 U を ドミネート するとは、 T が U に等価 (§3.5.1) であるか、 あるいは、T と U のトップレベルの型コンストラクタが共通の要素を持っていて T が U よりも複雑な場合です。

The set of top-level type constructors ttcs(T) of a type T depends on the form of the type:

型 T の トップレベルの型コンストラクタ の集合 ttcs(T)は、 型の形に依存します。:

       型指定子に対して、
       ttcs(p.c) = {c};
       パラメータ化された型に対して、
       ttcs(p.c[targs]) = {c};
       シングルトン型に対して、
       ttcs(p.type) = ttcs(T) 。ただし p が型 T をもつとして;
       複合型に対して、
       ttcs(T1 with ... with Tn) = ttcs(T1)∪ ... ∪ttcs(Tn) 

コア型の 複雑さ complexity(T) も、型の形に依存する整数です:

       型指定子に対して、
       complexity(p.c) = 1 + complexity(p)
       パラメータ化された型に対して、
       complexity(p.c[targs]) = 1 + Σcomplexity(targs)
       パッケージ p を表すシングルトン型に対して、
       complexity(p.type) = 0
       他のすべてのシングルトン型に対して、
       complexity(p.type) = 1 + complexity(T) 。ただし p が型 T をもつとして;
       複合型に対して
       complexity(T1 with ... with Tn) = Σcomplexity(Ti)


Example 7.2.2

When typing sort(xs) for some list xs of type List[List[List[Int]]], the sequence of types for which implicit arguments are searched is

型 List[List[List[Int]]] の、あるリスト xs に対して sort(xs) を 型付けするとき、暗黙の引数が検索される、型のシーケンスは次です。

   List[List[Int]] => Ordered[List[List[Int]]],
   List[Int] => Ordered[List[Int]]
   Int => Ordered[Int]

All types share the common type constructor scala.Function1, but the complexity of the each new type is lower than the complexity of the previous types . Hence, the code typechecks .

すべての型は共通の型コンストラクタ scala.Function1 を共有しますが、 しかし、各新しい型の複雑さは前の型の複雑さより低いです。 ですから、コードは型チェックを通ります。


Example 7.2.3

Let ys be a list of some type which cannot be converted to Ordered .

ys を Ordered へ変換できないある型のリストとします。たとえば、

   val ys = List(new IllegalArgumentException,new ClassCastException,new Error)

Assume that the definition of magic above is in scope . Then the sequence of types for which implicit arguments are searched is

前に書いた magic の定義がスコープ中にあると仮定します。 このとき、暗黙の引数が検索される、型のシーケンスは次です。

   Throwable => Ordered[Throwable],
   Throwable => Ordered[Throwable],
   ...

Since the second type in the sequence is equal to the first, the compiler will issue an error signalling a divergent implicit expansion .

シーケンスの 2 番目の型は最初の型と等価ですから、 コンパイラは暗黙展開の不一致を知らせるエラーを発行するでしょう。



7.3 ビュー (Views)

Implicit parameters and methods can also define implicit conversions called views . A view from type S to type T is defined by an implicit value which has function type S =>T or (=>S)=>T or by a method convertible to a value of that type .

暗黙のパラメータとメソッドも、 ビュー と呼ばれる暗黙の変換を 定義できます。 型 S から型 T へのビューは、関数型 S=>T あるいは (=>S)=>T をもつ暗黙の値によって、あるいはその型の値に変換可能なメソッドによって、 定義されます。

Views are applied in two situations .

1. If an expression e is of type T , and T does not conform to the expression's expected type pt . In this case an implicit v is searched which is applicable to e and whose result type conforms to pt . The search proceeds as in the case of implicit parameters, where the implicit scope is the one of T => pt . If such a view is found, the expression e is converted to v(e) .

ビューは、2 つの状況で適用されます。

1. もし式 e の型が T で、T が式の要請型 pt に適合しない場合。 この場合、e に適用可能でその結果型が pt に適合する、暗黙の v が検索されます。 検索は暗黙のパラメータの場合と同じように進み、そこでは暗黙のスコープは T => pt のそれです。 もしそのようなビューが見つかれば、式 e は v(e) に変換されます。

2. In a selection e.m with e of type T , if the selector m does not denote a member of T . In this case, a view v is searched which is applicable to e and whose result contains a member named m . The search proceeds as in the case of implicit parameters, where the implicit scope is the one of T . If such a view is found, the selection e.m is converted to v(e).m .

2. e の型が T で、e の選択 e.m 中で、セレクタ m が T のメンバーを表さない場合。 この場合、e に適用可能でその結果が m という名前のメンバーを含む、 ビュー v が検索されます。 検索は暗黙のパラメータの場合と同じように進み、そこでは暗黙のスコープは T のそれです。 もしそのようなビューが見つかれば、選択 e.m は v(e).m に変換されます。

The implicit view, if it is found, can accept is argument e as a call-by-value or as a call-by-name parameter . However, call-by-value implicits take precedence over call-by-name implicits .

As for implicit parameters, overloading resolution is applied if there are several possible candidates (of either the call-by-value or the call-by-name category) .

暗黙のビューが受け入れできるのは、もしそれが見つかれば、 値呼出しあるいは名前呼び出しパラメータとしての引数 e です。 しかし、暗黙の値呼出しは暗黙の名前呼出しよりも優先順位が高くなります。

暗黙のパラメータについては、もし複数の可能な候補 (値呼出しあるいは名前呼出しカテゴリのいずれでも)があれば、 オーバーロード解決が適用されます。


Example 7.3.1 クラス scala.Ordered[A] は、次のメソッドを含みます。

   def <= [B >: A](that: B)(implicit b2ordered: B => Ordered[B]): Boolean

型 List[Int] の 2 つのリスト xs と ys があるとし、 §7.2 で定義された list2ordered と int2ordered メソッドがスコープ中にあると仮定します。

このとき、操作

   xs <= ys

は正しく、そして次へ展開されます。

   list2ordered(xs)(int2ordered).<=
     (ys)
     (xs => list2ordered(xs)(int2ordered))

The first application of list2ordered converts the list xs to an instance of class Ordered, whereas the second occurrence is part of an implicit parameter passed to the <= method .

list2ordered の最初の適用は、リスト xs をクラス Ordered のインスタンスへ 変換するのに対して、2 番目の出現は、<= メソッドに渡される暗黙のパラメータの 一部です。



7.4 コンテキスト境界と可視境界(ビュー境界) (Context Bounds and View Bounds)

構文:

   TypeParam ::= (id | '_') [TypeParamClause] ['>:' Type] ['<:'Type]
                 {'<%' Type} {':' Type}

A type parameter A of a method or non-trait class may have one or more view bounds A <% T . In this case the type parameter may be instantiated to any type S which is convertible by application of a view to the bound T .

メソッド/非トレイトクラスの型パラメータ A は、1 つ以上の可視境界 (view bound) A <% T を持てます。 この場合、型パラメータは、境界 T へのビュー適用により変換可能な、 任意の型 S へインスタンス化されます。

A type parameter A of a method or non-trait class may also have one or more context bounds A : T . In this case the type parameter may be instantiated to any type S for which evidence exists at the instantiation point that S satisfies the bound T . Such evidence consists of an implicit value with type T[S] .

メソッド/非トレイトクラスの型パラメータ A は、1 つ以上のコンテキスト境界 A : T も持てます。 この場合、型パラメータは、 型 S が 境界 T をみたすインスタンス化地点でその 証拠(evidence) が存在するような、任意の型 S へインスタンス化されるでしょう。 そのような証拠は、型 T[S] をもつ暗黙の値からなります。

A method or class containing type parameters with view or context bounds is treated as being equivalent to a method with implicit parameters . Consider first the case of a single parameter with view and/or context bounds such as:

可視/コンテキスト境界をもつ型パラメータを含むメソッド/クラスは、 暗黙のパラメータをもつメソッドと同じように扱われます。 はじめに、次のような可視あるいはコンテキストあるいはその両方の境界をもつ、 ただ 1 つのパラメータの場合を考えます。

   def f[A <% T1 ... <% Tm : U1 : Un](ps): R = ...

このとき、上のメソッド定義は次へ展開されます。

   def f[A](ps)(implicit v1 : A => T1 ,..., vm : A => Tm ,
                         w1 : U1[ A ],..., wn : Un[ A ]): R = ...

where the vi and wj are fresh names for the newly introduced implicit parameters . These parameters are called evidence parameters .

ここで vi と wj は、新たに導入された暗黙のパラメータのための新規の名前です。 これらのパラメータは 証拠パラメータ(evidence parameters) と呼ばれます。

If a class or method has several view- or context-bounded type parameters, each such type parameter is expanded into evidence parameters in the order they appear and all the resulting evidence parameters are concatenated in one implicit parameter section . Since traits do not take constructor parameters, this translation does not work for them . Consequently, type-parameters in traits may not be view- or context-bounded . Also, a method or class with view- or context bounds may not define any additional implicit parameters .

もしクラス/メソッドが、複数の可視-/コンテキスト- 境界付けられた型パラメータを持つなら、 そのような各型パラメータは出現順に証拠パラメータへ展開され、 得られるすべての証拠パラメータは 1 つの暗黙のパラメータ部にまとめられます。 トレイトはコンストラクタパラメータをとらないので、 この変換処理はそれらには機能しません。 したがって、トレイト中の型パラメータは、可視-/コンテキスト-境界付きではありません。 同様に、可視-/コンテキスト-境界をもつメソッド/クラスは、 いかなる追加の暗黙のパラメータも定義できません。


Example 7.4.1 Example 7.3.1 中で言及された <= メソッドは、次のように、 より簡潔に宣言できます。

   def <= [B >: A <% Ordered[B]](that: B): Boolean



7.5 マニフェスト (Manifests)

Manifests are type descriptors that can be automatically generated by the Scala compiler as arguments to implicit parameters . The Scala standard library contains a hierarchy of four manifest classes, with OptManifest at the top . Their signatures follow the outline below .

マニフェスト(目録)は、暗黙のパラメータへの引数として、 Scala コンパイラによって自動的に生成される、型ディスクリプタです。 Scala 標準ライブラリは 4 つのマニフェストクラスの階層構造を含み、 トップは OptManifest です。 次はそれらシグニチャの概観です。

   trait OptManifest[+T]
   object NoManifest extends OptManifest[Nothing]
   trait ClassManifest[T] extends OptManifest[T]
   trait Manifest[T] extends ClassManifest[T]

If an implicit parameter of a method or constructor is of a subtype M[T] of class OptManifest[T], a manifest is determined for M[S], according to the following rules .

もしメソッド/コンストラクタの暗黙のパラメータの型がクラス OptManifest[T] のサブ型 M[T] なら、次の規則に従って、 M[S] に対するマニフェスト が決まります。

First if there is already an implicit argument that matches M[T], this argument is selected .

Otherwise, let Mobj be the companion object scala.reflect.Manifest if M is trait Manifest, or be the companion object scala.reflect.ClassManifest otherwise . Let M´ be the trait Manifest if M is trait Manifest, or be the trait OptManifest otherwise . Then the following rules apply .

最初に、もしすでに M[T] にマッチする暗黙の引数があるなら、 その引数が選ばれます。

そうでない場合、ここで、もし M がトレイト Manifest なら、Mobj を scala.reflect.Manifest のコンパニオンオブジェクトとし、そうでなければ、 Mobj を scala.reflect.ClassManifest のコンパニオンオブジェクトとします。 もし M がトレイト Manifest なら、M´を トレイト Manifest とし、 そうでなければ M´ をトレイト OptManifest とします。 このとき次の規則が適用されます。

1. If T is a value class or one of the classes Any, AnyVal, Object, Null, or Nothing, a manifest for it is generated by selecting the corresponding manifest value Manifest.T , which exists in the Manifest module .

2. If T is an instance of Array[S], a manifest is generated with the invocation Mobj.arrayType[S](m), where m is the manifest determined for M[S] .

3. If T is some other class type S#C[U1,...,Un] , where the prefix type S cannot be statically determined from the class C , a manifest is generated with the invocation Mobj.classType[T](m0 , classOf[T], ms) , where m0 is the manifest determined for M´[S] and ms are the manifests determined for M´[U1],...,M´[Un] .

1. もし T が値クラスあるいは、Any、AnyVal、Object、Null、Nothing の 1 つなら、 それに対するマニフェストは、Manifest モジュール中に存在する、 対応するマニフェスト値 Manifest.T を選ぶことで作成されます。

2. もし T が Array[S] のインスタンスなら、マニフェストは、Mobj.arrayType[S](m) の呼び出しで作成されます。ここで m は M[S] に対して決定されるマニフェストです。

3. もし T が他のあるクラス型 S#C[U1,...,Un] なら、 ここで前置型 S はクラス C から静的に決定できないとして、マニフェストは Mobj.classType[T](m0 , classOf[T], ms) の呼び出しで作成されます。 ここで m0 は M´[S] に対して決定されるマニフェストであり、 ms は M´[U1],...,M´[Un] に対して決定されるマニフェストです。

4. If T is some other class type with type arguments U1,...,Un , a manifest is generated with the invocation Mobj.classType[T](classOf[T], ms) , where ms are the manifests determined for M´[U1],...,M´[Un] .

5. If T is a singleton type p.type, a manifest is generated with the invocation Mobj.singleType[T](p)

6. If T is a refined type T´{R}, a manifest is generated for T´ . (That is, refinements are never reflected in manifests) .

4. もし T が型引数 U1,...,Un をもつ他のあるクラス型なら、マニフェストは Mobj.classType[T](classOf[T], ms) の呼び出しで作成されます。ただしここで ms は M´[U1],...,M´[Un] に対して決定されるマニフェストです。

5. もし T がシングルトン型 p.type なら、マニフェストは Mobj.singleType[T](p) の呼び出しで作成されます。

6. もし T が細別型 T´{R} なら、マニフェストは T´に対して作成されます。 (すなわち、細別はマニフェストに決して反映されません)。

7. If T is an intersection type T1 with,...,with Tn , where n > 1, the result depends on whether a full manifest is to be determined or not . If M is trait Manifest, then a manifest is generated with the invocation Manifest.intersectionType[T](ms) , where ms are the manifests determined for M[T1],...,M[Tn]. Otherwise, if M is trait ClassManifest, then a manifest is generated for the intersection dominator (§3.7) of the types T1,...,Tn .

8. If T is some other type, then if M is trait OptManifest, a manifest is generated from the designator scala.reflect.NoManifest . If M is a type different from OptManifest, a static error results .

7. もし T が論理積型 T1 with,...,with Tn (n > 1)なら、その結果は、 フルのマニフェストが決定されるか否かによります。 もし M がトレイト Manifest なら、マニフェストは Manifest.intersectionType[T](ms) の呼び出しで作成されます。 ただしここで ms は M[T1],...,M[Tn] に対して決定されるマニフェストです。 そうでなければ、もし M がトレイト ClassManifest なら、 マニフェストは型 T1,...,Tn の論理積ドミネータ (§3.7)に対して作成されます。

8. もし T が他のある型なら、そのときもし M がトレイト OptManifest なら、 マニフェストは指定子 scala.reflect.NoManifest から作成されます。 もし M が OptManifest と異なる型なら、静的エラーとなります。

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2011年03月03日 10:12
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。