Skip to content
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

3.4.1 Cannot infer that the implementation of the parent class in a trait is type equivalent #20390

Open
Christewart opened this issue May 12, 2024 · 1 comment
Labels
area:typer itype:bug stat:needs minimization Needs a self contained minimization

Comments

@Christewart
Copy link

Christewart commented May 12, 2024

Compiler version

3.4.1

Minimized code

This can be reproduced by running wallet/compile on this commit: Christewart/bitcoin-s-core@cbec2d9

Parent traits

trait TxCRUDComponent[DbEntryType <: TxDB] {
  self: CRUD[DbEntryType, DoubleSha256DigestBE] =>
}

trait TxDAO[DbEntryType <: TxDB] {
  abstract class TxTable[DbEntryType](
      tag: profile.api.Tag,
      schemaName: Option[String],
      tableName: String
  ) extends Table[DbEntryType](tag, schemaName, tableName) {
    def txIdBE: Rep[DoubleSha256DigestBE]
  }

  type DbTable = TxTable[DbEntryType]
  override val table: TableQuery[DbTable]
}

Subclass that is failing to compile

case class IncomingTransactionDAO() extends TxDAO[IncomingTransactionDb] {

  override val table: slick.lifted.TableQuery[
    IncomingTransactionDAO.this.IncomingTransactionTable] = {
    TableQuery[IncomingTransactionTable]
  }
  class IncomingTransactionTable(tag: Tag)
      extends TxTable[IncomingTransactionDb](
        tag,
        schemaName,
        "wallet_incoming_txs"
      )
}

Output

[error] -- [E164] Declaration Error: /Users/chris/dev/bitcoin-s/wallet/src/main/scala/org/bitcoins/wallet/models/IncomingTransactionDAO.scala:17:15                                                         
[error] 17 |  override val table: slick.lifted.TableQuery[                                                                                                                                                  
[error]    |               ^                                                                                                                                                                                
[error]    |error overriding value table in trait TxDAO of type slick.lifted.TableQuery[IncomingTransactionDAO.this.DbTable];                                                                               
[error]    |  value table of type slick.lifted.TableQuery[IncomingTransactionDAO.this.IncomingTransactionTable] has incompatible type                                                                       
[error]    |----------------------------------------------------------------------------                                                                                                                    
[error]    | Explanation (enabled by `-explain`)                                                                                                                                                            
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                                                                                                                     
[error]    | I tried to show that                                                                                                                                                                           
[error]    |   slick.lifted.TableQuery[IncomingTransactionDAO.this.IncomingTransactionTable]                                                                                                                
[error]    | conforms to                                                                                                                                                                                    
[error]    |   slick.lifted.TableQuery[IncomingTransactionDAO.this.DbTable]                                                                                                                                 
[error]    | but none of the attempts shown below succeeded:                                                                                                                                                
[error]    |                                                                                                                                                                                                
[error]    |   ==> slick.lifted.TableQuery[IncomingTransactionDAO.this.IncomingTransactionTable]  <:  slick.lifted.TableQuery[IncomingTransactionDAO.this.DbTable]                                          
[error]    |     ==> IncomingTransactionDAO.this.DbTable  <:  IncomingTransactionDAO.this.IncomingTransactionTable                                                                                          
[error]    |       ==> IncomingTransactionDAO.this.TxTable[   org.bitcoins.core.api.wallet.db.IncomingTransactionDb]  <:  IncomingTransactionDAO.this.IncomingTransactionTable  = false                     
[error]    |                                                                                                                                                                                                
[error]    | The tests were made under the empty constraint                                                                                                                                                 
[error]     ----------------------------------------------------------------------------                                                                

Expectation

This should compile I think since IncomingTransactionTable is a subclass of TxTable[IncomingTransactionDb] ?

@Christewart Christewart added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 12, 2024
@Gedochao Gedochao added area:typer stat:needs minimization Needs a self contained minimization and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 13, 2024
@Gedochao
Copy link

@Christewart we'll need to minimise this outside of the repo. Can you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug stat:needs minimization Needs a self contained minimization
Projects
None yet
Development

No branches or pull requests

2 participants